Expand description
XDR runtime encoding/decoding
This crate provides runtime support for encoding and decoding XDR data. It is intended to be used with code generated by the “xdrgen” crate, but it can also be used with hand-written code.
It provides two key traits - Pack
and Unpack
- which all
encodable types must implement. It also provides the helper
functions pack()
and unpack()
to simplify the API.
By default, this does not implement codecs for i8
or u8
. This is because
encoding individual bytes is quite inefficient, as they’re all padded up to
32 bits (4 bytes). This doesn’t matter for individual items, but arrays of
bytes should be represented by opaque arrays (static size) or flex arrays
(dynamic size) (or strings for character data).
However, some protocols are mis-specified to use byte arrays (I’m looking at
you, gluster), so the option to support the exists. You can enable byte codec
with the bytecodec
feature.
Modules§
- record
- XDR record marking
Structs§
Enums§
- Error
Kind - The kind of an error.
Traits§
- Pack
- Basic packing trait.
- Read
- The
Read
trait allows for reading bytes from a source. - Result
Ext - Additional methods for
Result
, for easy interaction with this crate. - Unpack
- Basic unpacking trait
- Write
- A trait for objects which are byte-oriented sinks.
Functions§
- pack
- Serialization (packing) helper.
- pack_
array - Pack a fixed-size array.
- pack_
flex - Pack a dynamically sized array, with size limit check.
- pack_
opaque_ array - Pack a fixed-size byte array
- pack_
opaque_ flex - Pack a dynamically sized opaque array, with size limit check.
- pack_
string - Pack a string with size limit check.
- padding
- Compute XDR padding.
- unpack
- Deserialization (unpacking) helper function
- unpack_
array - Unpack a fixed-sized array
- unpack_
flex - Unpack a (perhaps) length-limited array
- unpack_
opaque_ array - Unpack a fixed-sized opaque array
- unpack_
opaque_ flex - Unpack a (perhaps) length-limited opaque array
- unpack_
string - Unpack (perhaps) length-limited string
Type Aliases§
- Result
- Convenient wrapper around
std::Result
.