Crates.io | wyre-derive |
lib.rs | wyre-derive |
version | 0.2.16 |
source | src |
created_at | 2024-06-22 08:35:02.828288 |
updated_at | 2024-09-24 19:11:31.696014 |
description | wyre derive macros |
homepage | |
repository | https://github.com/u-tra/wyre |
max_upload_size | |
id | 1280271 |
size | 12,202 |
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.
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"
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! 🎉");
}
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.
We welcome contributions! Please see our contributing guidelines. Don’t be shy – jump right in!