Skip to main content

encode_timestamp_choice

Function encode_timestamp_choice 

Source
pub fn encode_timestamp_choice(
    buf: &mut BytesMut,
    ts: &BACnetTimeStamp,
) -> Result<(), Error>
Expand description

Encode a BACnetTimeStamp as a bare CHOICE element (no enclosing field tag).

Used where a production lists BACnetTimeStamp as a bare CHOICE item — e.g. the eventTimeStamps [3] SEQUENCE OF BACnetTimeStamp inside GetEventInformation-ACK. encode_timestamp wraps this in the enclosing field’s context tag pair instead.

Tag forms per Clause 20.2.1.5: time [0] is the CHOICE’s only alternative over a primitive base type, so it encodes as a context-specific primitive tag 0 of length 4 holding the raw Time octets (the opening-tag-0 wrapper around an application-tagged Time is NOT conformant); sequence-number [1] is a primitive context tag 1 (contents constrained to 0..=65535 by the public variant’s u16 payload); datetime [2] tags the constructed BACnetDateTime, so it encodes as opening tag 2 / application-tagged Date / application-tagged Time / closing tag 2.