| Crates.io | bragi |
| lib.rs | bragi |
| version | 0.2.0 |
| created_at | 2025-04-30 22:53:19.023288+00 |
| updated_at | 2025-05-14 12:53:23.248571+00 |
| description | Helper crate used in code generated by bragi |
| homepage | |
| repository | https://github.com/managarm/bragi |
| max_upload_size | |
| id | 1655547 |
| size | 19,853 |
Helper crate used in code generated by bragi and Rust software written for Managarm.
The bindings can be generated from a build.rs file with the help of the
bragi-build crate.
Given the example bragi message:
message ExampleMessage 1 {
head(128):
uint32 a;
uint32 b;
}
// Include the generated bindings.
bragi::include_binding!(mod bindings = "bindings.rs");
Vec<u8>fn encode_an_example_message() -> std::io::Result<Vec<u8>> {
// Create an example message
let msg = bindings::ExampleMessage::new(1337, 420);
// Encode an example message into a byte buffer.
let buffer = bragi::message_head_to_bytes(&msg)?;
Ok(buffer)
}
Vec<u8>fn decode_an_example_message(buffer: &[u8]) -> std::io::Result<()> {
// Decode an example message
let msg: bindings::ExampleMessage = bragi::head_from_bytes(buffer)?;
// Print the decoded message
println!("a: {}", msg.a());
println!("b: {}", msg.b());
Ok(())
}
This crate is licensed under the MIT license. See the LICENSE file for more details.