Expand description
XDR (External Data Representation) codec – RFC 4506.
Every ONC RPC protocol encodes its arguments and results with XDR. The rules that matter for reading the protocol crates built on this one:
- Integers are big-endian and always occupy a multiple of 4 bytes. A
u8, abool, and au32all take 4 bytes on the wire. - Variable-length data (opaque byte strings, arrays) is length-prefixed by a 4-byte count and then zero-padded up to the next 4-byte boundary.
- Fixed-length opaque data carries no length prefix – NFSv2’s 32-byte file handle is 32 raw bytes, whereas NFSv3’s is a prefixed byte string.
- Discriminated unions lead with a 4-byte discriminant.
Pack and Unpack are the two traits every wire type implements.
Most types get them from #[derive(XdrCodec)], re-exported here; types
whose encoding does not follow the mechanical field-by-field rule implement
them by hand.
§Decoding untrusted input
Every length and count on the wire is chosen by the peer. util provides
the hardened readers the protocol crates use instead of sizing an
allocation from a declared length directly – see PREALLOC_CAP.
Re-exports§
pub use self::util::PREALLOC_CAP;pub use self::util::pack_string;pub use self::util::read_bytes;pub use self::util::skip_pad;pub use self::util::string_packed_size;pub use self::util::unpack_string;pub use self::util::vec_with_capacity;pub use self::util::write_pad;
Modules§
- util
- Padding arithmetic and length-hardened reads for XDR.
Structs§
- Bounded
List - A
Listthat refuses elements once its encoded size would exceed a cap. - List
- Represents a sequence of optional values in NFS3.
- Opaque
- XDR variable-length opaque data – a length-prefixed, zero-padded byte string (RFC 4506 sec. 4.10).
- Void
- The XDR “void” type – zero bytes on the wire.
Enums§
- Error
- Something went wrong encoding to or decoding from the XDR wire format.
Traits§
Type Aliases§
- Result
- Result of an XDR encode or decode operation.
Derive Macros§
- XdrCodec
- Derives XDR
PackandUnpackfor a struct or enum.