rustnetconf-yang
Compile-time typed Rust structs generated from YANG models, for use with
rustnetconf. The generated types serialize to NETCONF-ready XML.
Quick start
The generated code is behind the generated feature, which is off by
default. You must enable it or the ietf_* modules will not exist:
[]
= { = "0.1", = ["generated"] }
Then use a bundled model:
use ;
use ToNetconfXml;
let config = Interfaces ;
// Serialize to NETCONF-ready XML for `edit-config`:
let xml = config.to_xml.unwrap;
Which models are available?
The crate bundles these IETF models, generated at build time:
ietf_interfaces(fromietf-interfaces.yang)ietf_ip(fromietf-ip.yang)- plus supporting types from
ietf-yang-types/ietf-inet-types
Each module exposes a NAMESPACE const and structs named in PascalCase
after the YANG nodes (e.g. container interfaces -> Interfaces, list
interface -> Interface). YANG names that are Rust keywords are suffixed
with _ (e.g. leaf type -> field type_).
Using your own YANG models
Code is generated from the yang-models/ directory of this crate, not
of your project: the build script reads $CARGO_MANIFEST_DIR/yang-models,
which resolves to this crate's source in the Cargo registry cache when used
as a dependency. To generate types from custom .yang files you must vendor
this crate (e.g. a git/path dependency or fork) and add your models to its
yang-models/ directory.