wyre-derive

Crates.iowyre-derive
lib.rswyre-derive
version0.2.16
sourcesrc
created_at2024-06-22 08:35:02.828288
updated_at2024-09-24 19:11:31.696014
descriptionwyre derive macros
homepage
repositoryhttps://github.com/u-tra/wyre
max_upload_size
id1280271
size12,202
incredimo (incredimo)

documentation

README

[wyre]

Welcome to wyre – the super lightweight serialization and communication crate that's so efficient, it practically serializes your data in its sleep. If you’ve ever thought, "Gee, I wish my serialization was as snappy as my sarcasm," then you're in the right place.

Features

  • Binary Serialization: Because plain text is for chumps.
  • JSON Serialization: For when you need to look sophisticated in front of your friends.
  • RON Serialization: Not the guy from accounting, but Rusty Object Notation.
  • MessagePack Serialization: Like moving to a tiny house – small but mighty.
  • TOML Serialization: For those who like to keep their configs neat and tidy.
  • Custom Derivation: Macro-based custom derive support for structs and enums, because writing boilerplate is so last decade.

Usage

First things first, add wyre to your Cargo.toml. This step is critical. Skipping it will result in... nothing working.

[dependencies]
wyre = "0.1.0"

Example

Here's a simple example to get you started. Even your grandma could follow this – if she’s into Rust, that is.

use wyre::{SerBin, DeBin, SerJson, DeJson, SerMsgPack, DeMsgPack};

#[derive(SerBin, DeBin, SerJson, DeJson, SerMsgPack, DeMsgPack, PartialEq, Debug)]
struct TestStruct {
    a: u32,
    b: String,
    c: Vec<u8>,
}

fn main() {
    let test_message = TestStruct {
        a: 42,
        b: "Hello, World!".to_string(),
        c: vec![1, 2, 3, 4, 5],
    };

    // Binary Serialization
    let serialized_bin = test_message.serialize_bin();
    let deserialized_bin = TestStruct::deserialize_bin(&serialized_bin).unwrap();
    assert_eq!(test_message, deserialized_bin);
    println!("Binary serialization and deserialization succeeded! 🎉");

    // JSON Serialization
    let serialized_json = test_message.serialize_json();
    let deserialized_json = TestStruct::deserialize_json(&serialized_json).unwrap();
    assert_eq!(test_message, deserialized_json);
    println!("JSON serialization and deserialization succeeded! 🎉");

    // MessagePack Serialization
    let serialized_wyre = test_message.pack();
    let deserialized_wyre = TestStruct::depack(&serialized_wyre).unwrap();
    assert_eq!(test_message, deserialized_wyre);
    println!("MessagePack serialization and deserialization succeeded! 🎉");
}

License

This project is licensed under the MIT or Apache-2.0 license. Because sharing is caring.

And let's be honest, in today's world, every piece of code is just a beautifully mixed cocktail of copy-pasted snippets from Stack Overflow and GitHub.

Contributing

We welcome contributions! Please see our contributing guidelines. Don’t be shy – jump right in!

Commit count: 0

cargo fmt