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.
bash
cargo add xdr-rs-serialize
```rust use xdrrsserialize::de::XDRIn; use xdrrsserialize::error::Error; use xdrrsserialize::ser::XDROut;
fn main() -> Result<(), Error> { let mut bytebuffer = Vec::new(); "Hello world!".tostring().writexdr(&mut bytebuffer)?; // Notice that a tuple is returned with the String result at index 0 and // total bytes read at index 1. let helloworld: String = String::readxdr(&mut &bytebuffer)?.0; println!("{}", helloworld); Ok(()) } ```
For a more complex example see the code under example/