10 releases

0.1.15 Aug 15, 2024
0.1.14 Aug 15, 2024
0.1.7 Jun 23, 2024

#340 in Data structures

Download history 319/week @ 2024-06-20 25/week @ 2024-06-27 47/week @ 2024-07-04 29/week @ 2024-07-25 4/week @ 2024-08-01 414/week @ 2024-08-15

421 downloads per month

MIT license

125KB
3K SLoC

[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_msgpack = test_message.serialize_msgpack();
    let deserialized_msgpack = TestStruct::deserialize_msgpack(&serialized_msgpack).unwrap();
    assert_eq!(test_message, deserialized_msgpack);
    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!

Dependencies

~3.5MB