Expand description
Application-tagged primitive encode/decode per ASHRAE 135-2020 Clause 20.2.
Provides both raw value codecs (no tag header) and application/context-tagged convenience functions for all BACnet primitive types.
The bounded scalar encoders also have _to_sink entrypoints accepting
crate::sink::EncodeSink. Each appends its complete value, including any
tag header, in one atomic write and returns the appended byte count. Known
capacity shortages never call the sink; a custom sink’s error is unchanged.
The scalar staging buffer is at most eleven bytes. These functions preserve
the existing encoders’ input semantics and do not add value validation.
encode_timestamp_choice_to_sink and encode_timestamp_to_sink extend
the same one-write contract to complete timestamps, with twelve-byte and
sixteen-byte staging bounds respectively. These bounds describe encoded
output, not the full call stack.
The CharacterString, OCTET STRING and BIT STRING _to_sink encoders write
a header and a caller’s payload as one value with
EncodeSink::write_parts.
CharacterStringRef and ApplicationValueRef read strings and
application-tagged values without copying them. Those, the scalar
decoders and the sink encoders need no allocator; the BytesMut encoders
and the owned PropertyValue decoders need alloc.
Modules§
- charset
- Character set identifiers.
Structs§
- Character
String Ref - A CharacterString’s contents, borrowed from the octets they were decoded from: the character-set octet, then the string in that character set (Clause 20.2.9).
Enums§
- Application
Value Ref - One application-tagged value of a primitive datatype (Clause 20.2.2 to 20.2.14), borrowed from the octets it was decoded from.
Constants§
- MAX_
TIMESTAMP_ SEQUENCE_ NUMBER - Largest encodable
sequence-numbervalue: the production constrains it toUnsigned (0..65535). - PRIORITY_
DATE_ TIME_ TAG - The context tag of the date-time choice of
BACnetPriorityValue.
Functions§
- character_
string_ len - Return the encoded length of a character string (charset byte + UTF-8
bytes). Only with
alloc: the sink encoders refuse an over-long string withSinkFullinstead. - decode_
application_ value - Decode a single application-tagged value from
dataatoffset. - decode_
application_ value_ ref - Decode one application-tagged primitive value from
dataatoffset, without copying it; returns the value and the offset past it. - decode_
bit_ string - Decode a bit string from content bytes.
- decode_
bit_ string_ ref - Decode a bit string from content bytes without copying its data octets.
- decode_
character_ string - Decode a character string from content bytes.
- decode_
double - Decode an IEEE-754 double-precision float from 8 big-endian bytes.
- decode_
priority_ date_ time - Decode the date-time choice of
BACnetPriorityValueatoffset, returning the Date, the Time and the offset past the closing tag. - decode_
real - Decode an IEEE-754 single-precision float from 4 big-endian bytes.
- decode_
signed - Decode a signed integer from two’s-complement big-endian bytes (1-4 bytes).
- decode_
timestamp - Decode a BACnetTimeStamp from inside a context opening/closing tag pair.
- decode_
timestamp_ choice - Decode a bare-CHOICE
BACnetTimeStampstarting atoffset. - decode_
unsigned - Decode an unsigned integer from big-endian bytes (1-8 bytes).
- decode_
unsigned_ u8 - Decode an unsigned integer that fits in a
u8from 1-8 big-endian bytes. Leading zero bytes are accepted; values aboveu8::MAXare rejected. - decode_
unsigned_ u16 - Decode an unsigned integer that fits in a
u16from 1-8 big-endian bytes. Leading zero bytes are accepted; values aboveu16::MAXare rejected. - decode_
unsigned_ u32 - Decode an unsigned integer that fits in a
u32from 1-8 big-endian bytes. Leading zero bytes are accepted; values aboveu32::MAXare rejected. - encode_
app_ bit_ string - Encode an application-tagged BitString. It keeps its own code rather than
delegating to
encode_app_bit_string_to_sink: pastu32::MAXoctets it saturates the length, where the sink encoder refuses. - encode_
app_ bit_ string_ to_ sink - Append an application-tagged BIT STRING. Returns the octets appended.
- encode_
app_ boolean - Encode an application-tagged Boolean.
- encode_
app_ boolean_ to_ sink - Append an application-tagged Boolean with its value in the header and no contents.
- encode_
app_ character_ string - Encode an application-tagged CharacterString (UTF-8). Delegates to
encode_app_character_string_to_sink; a string too long for a header’s 32-bit length isError::Encode, with nothing written. - encode_
app_ character_ string_ to_ sink - Append an application-tagged UTF-8 CharacterString. Returns the octets appended.
- encode_
app_ date - Encode an application-tagged Date.
- encode_
app_ date_ to_ sink - Append an application-tagged Date preserving its four fields without validation.
- encode_
app_ double - Encode an application-tagged Double (f64).
- encode_
app_ double_ to_ sink - Append an application-tagged Double preserving every payload bit.
- encode_
app_ enumerated - Encode an application-tagged Enumerated.
- encode_
app_ enumerated_ to_ sink - Append an application-tagged Enumerated with its minimum-width contents.
- encode_
app_ null - Encode an application-tagged Null.
- encode_
app_ null_ to_ sink - Append an application-tagged Null with no contents.
- encode_
app_ object_ id - Encode an application-tagged ObjectIdentifier.
- encode_
app_ object_ id_ to_ sink - Append an application-tagged ObjectIdentifier preserving its 10-bit type and 22-bit instance.
- encode_
app_ octet_ string - Encode an application-tagged OctetString. It keeps its own code rather
than delegating to
encode_app_octet_string_to_sink: pastu32::MAXoctets it saturates the length, where the sink encoder refuses. - encode_
app_ octet_ string_ to_ sink - Append an application-tagged OCTET STRING. Returns the octets appended.
- encode_
app_ real - Encode an application-tagged Real (f32).
- encode_
app_ real_ to_ sink - Append an application-tagged Real preserving every payload bit.
- encode_
app_ signed - Encode an application-tagged Signed.
- encode_
app_ signed_ to_ sink - Append an application-tagged Signed with its minimum-width contents.
- encode_
app_ time - Encode an application-tagged Time.
- encode_
app_ time_ to_ sink - Append an application-tagged Time preserving its four fields without validation.
- encode_
app_ unsigned - Encode an application-tagged Unsigned.
- encode_
app_ unsigned_ to_ sink - Append an application-tagged Unsigned with its minimum-width contents.
- encode_
bit_ string - Encode a bit string: leading unused-bits count followed by data bytes.
Delegates to
encode_bit_string_to_sink. - encode_
bit_ string_ to_ sink - Append a BIT STRING’s contents, without a tag: the unused-bit count, then
the data octets. Returns the octets appended. Like the
BytesMutencoder, it doesn’t check the count. - encode_
character_ string - Encode a UTF-8 character string with leading charset byte. Delegates to
encode_character_string_to_sink. - encode_
character_ string_ to_ sink - Append a UTF-8 CharacterString’s contents, without a tag: the character-set octet X’00’, then the string’s octets. Returns the octets appended.
- encode_
ctx_ bit_ string - Encode a context-tagged BitString. It keeps its own code rather than
delegating to
encode_ctx_bit_string_to_sink: pastu32::MAXoctets it saturates the length, where the sink encoder refuses. - encode_
ctx_ bit_ string_ to_ sink - Append a BIT STRING under context tag
tag. Returns the octets appended. - encode_
ctx_ boolean - Encode a context-tagged Boolean.
- encode_
ctx_ boolean_ to_ sink - Append a context-tagged Boolean with one content octet.
- encode_
ctx_ character_ string - Encode a context-tagged CharacterString (UTF-8). Delegates to
encode_ctx_character_string_to_sink; a string too long for a header’s 32-bit length isError::Encode, with nothing written. - encode_
ctx_ character_ string_ to_ sink - Append a UTF-8 CharacterString under context tag
tag. Returns the octets appended. - encode_
ctx_ date - Encode a context-tagged Date.
- encode_
ctx_ date_ to_ sink - Append a context-tagged Date preserving its four fields without validation.
- encode_
ctx_ double - Encode a context-tagged Double (f64).
- encode_
ctx_ double_ to_ sink - Append a context-tagged Double preserving every payload bit.
- encode_
ctx_ enumerated - Encode a context-tagged Enumerated.
- encode_
ctx_ enumerated_ to_ sink - Append a context-tagged Enumerated with its minimum-width contents.
- encode_
ctx_ object_ id - Encode a context-tagged ObjectIdentifier.
- encode_
ctx_ object_ id_ to_ sink - Append a context-tagged ObjectIdentifier preserving its 10-bit type and 22-bit instance.
- encode_
ctx_ octet_ string - Encode a context-tagged OctetString. It keeps its own code rather than
delegating to
encode_ctx_octet_string_to_sink: pastu32::MAXoctets it saturates the length, where the sink encoder refuses. - encode_
ctx_ octet_ string_ to_ sink - Append an OCTET STRING under context tag
tag. Returns the octets appended. - encode_
ctx_ real - Encode a context-tagged Real (f32).
- encode_
ctx_ real_ to_ sink - Append a context-tagged Real preserving every payload bit.
- encode_
ctx_ signed - Encode a context-tagged Signed.
- encode_
ctx_ signed_ to_ sink - Append a context-tagged Signed with its minimum-width contents.
- encode_
ctx_ unsigned - Encode a context-tagged Unsigned.
- encode_
ctx_ unsigned_ to_ sink - Append a context-tagged Unsigned with its minimum-width contents.
- encode_
double - Encode an IEEE-754 double-precision float (big-endian, 8 bytes).
- encode_
double_ to_ sink - Append the eight IEEE-754 octets of a Double in big-endian order without a tag.
- encode_
priority_ date_ time - Append one Priority_Array element holding a date-time: opening tag 1, the application-tagged Date and Time, closing tag 1 (twelve octets).
- encode_
property_ value - Encode a
PropertyValueas an application-tagged value. Only withalloc. - encode_
real - Encode an IEEE-754 single-precision float (big-endian, 4 bytes).
- encode_
real_ to_ sink - Append the four IEEE-754 octets of a Real in big-endian order without a tag.
- encode_
signed - Encode a signed integer using minimum octets, two’s complement, big-endian.
- encode_
signed_ to_ sink - Append a signed integer in the minimum two’s-complement width without a tag.
- encode_
timestamp - Encode a BACnetTimeStamp wrapped in a context opening/closing tag pair.
- encode_
timestamp_ choice - Encode a
BACnetTimeStampas a bare CHOICE element (no enclosing field tag). Delegates toencode_timestamp_choice_to_sinkthrough the growable buffer; the existing result type is retained. - encode_
timestamp_ choice_ to_ sink - Append a complete bare
BACnetTimeStampCHOICE in one sink write. - encode_
timestamp_ to_ sink - Append an outer context frame and its complete timestamp in one sink write.
- encode_
unsigned - Encode an unsigned integer using the minimum number of big-endian octets.
- encode_
unsigned_ to_ sink - Append an unsigned integer in the minimum big-endian width without a tag.
- signed_
len - Return the number of bytes needed to encode a signed value.
- unsigned_
len - Return the number of bytes needed to encode an unsigned value.
- validate_
application_ value - Check that an application-tagged value starts at
offsetand is structurally well formed, returning the offset just past it.