Function xdrgen::compile [] [src]

pub fn compile<P>(infile: P) -> Result<()> where
    P: AsRef<Path> + Display

Simplest possible way to generate Rust code from an XDR specification.

It is intended for use in a build.rs script:

extern crate xdrgen;

fn main() {
   xdrgen::compile("src/simple.x").unwrap();
}

Output is put into OUT_DIR, and can be included:

mod simple {
   use xdr_codec;

   include!(concat!(env!("OUT_DIR"), "/simple_xdr.rs"));
}

If your specification uses types which are not within the specification, you can provide your own implementations of Pack and Unpack for them.