Crates.io | xdr-rs-serialize |
lib.rs | xdr-rs-serialize |
version | 0.3.1 |
source | src |
created_at | 2019-09-27 21:12:00.92685 |
updated_at | 2022-05-20 13:27:21.121643 |
description | XDR object serialization for Rust |
homepage | https://github.com/kochavalabs/xdr-rs-serialize |
repository | https://github.com/kochavalabs/xdr-rs-serialize |
max_upload_size | |
id | 168247 |
size | 82,344 |
Xdr-rs-serialize is a library for facilitating the (de)serialization of rust objects into the XDR format.
This library can be added to your project by using cargo to install the xdr-rs-serialize crate.
cargo add xdr-rs-serialize
use xdr_rs_serialize::de::XDRIn;
use xdr_rs_serialize::error::Error;
use xdr_rs_serialize::ser::XDROut;
fn main() -> Result<(), Error> {
let mut byte_buffer = Vec::new();
"Hello world!".to_string().write_xdr(&mut byte_buffer)?;
// Notice that a tuple is returned with the String result at index 0 and
// total bytes read at index 1.
let hello_world: String = String::read_xdr(&mut &byte_buffer)?.0;
println!("{}", hello_world);
Ok(())
}
For a more complex example see the code under example/