Skip to main content

decode_lighting_command

Function decode_lighting_command 

Source
pub fn decode_lighting_command(
    data: &[u8],
    offset: usize,
) -> Result<(BACnetLightingCommand, usize), Error>
Expand description

Decode one unframed BACnetLightingCommand SEQUENCE at offset.

Returns the command and the offset just past its last field. Decoding stops at the first tag that isn’t the next optional field, so a caller that expects exactly one command must check that the returned offset reaches the end of its data, or the closing tag of its frame. A caller whose whole input must be one command uses decode_lighting_command_value instead, which checks that before it reports a field too wide for its type.

Field values aren’t range-checked here; the receiver does that. Failures come in three kinds:

  • contents that run past the end of data: Error::BufferTooShort;
  • any other malformed field (a missing operation, a REAL not four octets long, an Unsigned with no contents octets, or one of more than four that opens with a zero octet): Error::Decoding;
  • a well-formed command whose operation or fade time needs more than 32 bits, or whose priority needs more than 8: Error::OutOfRange, naming the first such field. A malformed field anywhere takes precedence.

Up to four contents octets, an Unsigned or ENUMERATED may open with zero octets; encode_lighting_command always writes the shortest form.