Skip to main content

Crate rustorb_cdr

Crate rustorb_cdr 

Source
Expand description

CDR (Common Data Representation) encoder and decoder.

Handles primitive and constructed IDL types with GIOP alignment rules and both byte orders.

  • Encoder and Decoder read and write primitives, strings, wide strings, sequences and encapsulations. Alignment is computed from the absolute stream offset, so a body that starts in the middle of a GIOP message keeps the alignment of the whole message.

  • CdrEncode and CdrDecode map Rust types to IDL types: integers and floats to their IDL counterparts, String to string, Vec to sequence, and fixed-size arrays to IDL arrays.

  • Octets is a sequence<octet> that shares its bytes: read from a message without copying (Decoder::read_octet_seq_shared) and written without copying into the message (Encoder::write_octet_seq_shared, when the encoder allows it).

Code set conversion is out of scope: string is read and written as bytes (UTF-8 when converted to String), and wchar/wstring use UTF-16. Negotiating other code sets is left to the ORB core. any, TypeCode and fixed are in the ORB core, which knows the types. long double is LongDouble, the IEEE 754 binary128 bits.

Valuetypes are written and read in pieces: Encoder::begin_value / Encoder::end_value and Decoder::read_value_header / Decoder::end_value handle the value tags, sharing (indirections) and chunking, and the caller writes or reads the state members in between.

Structs§

Decoder
Reads CDR from a byte slice.
Encoder
Writes CDR into a growable buffer.
LongDouble
A long double value, kept as its IEEE 754 binary128 bits: the sign in the top bit, a 15-bit exponent biased by 16383 and a 112-bit fraction.
Octets
A sequence<octet> that shares its bytes instead of copying them.
Segment
A point in a decoder’s buffer from which the stream offset restarts.

Enums§

ByteOrder
Byte order of a CDR stream.
CdrVersion
The GIOP version whose CDR rules a stream follows.
Error
Errors raised while encoding or decoding CDR.
ValueHeader
What Decoder::read_value_header found where a value was expected.

Constants§

SHARE_MIN
Octet sequences at least this long are shared rather than copied, by Decoder::read_octet_seq_shared and Encoder::write_octet_seq_shared. Shorter ones are cheaper to copy, and a short slice should not keep a large message buffer alive.

Traits§

CdrDecode
A type that can be read from CDR.
CdrEncode
A type that can be written as CDR.

Type Aliases§

Result
Result type of CDR operations.