Skip to main content

encode_property_reference_to_sink

Function encode_property_reference_to_sink 

Source
pub fn encode_property_reference_to_sink<S: EncodeSink + ?Sized>(
    sink: &mut S,
    reference: &PropertyReference,
) -> Result<usize, SinkFull>
Expand description

Append one complete BACnetPropertyReference in one sink write.

This preserves super::encode_property_reference’s accepted inputs and wire bytes. Its bounded assembly stages at most ten encoded bytes. A known shortage returns the total required and available lengths without calling write; an arbitrary sink refusal is returned unchanged. On failure, earlier output, the cursor, container length and unused tail remain unchanged. Earlier successful encoder calls stay committed if a later call fails.

No semantic validation is added. The staging bound is not a whole-stack bound, and the crate still requires std or alloc with a bounded sink.

use bacnet_encoding::constructed::encode_property_reference_to_sink;
use bacnet_types::constructed::PropertyReference;
use bacnet_types::enums::PropertyIdentifier;

let reference = PropertyReference {
    property_identifier: PropertyIdentifier::PRESENT_VALUE,
    property_array_index: None,
};
let mut storage = [0xA5; 2];
let mut tail = &mut storage[..];
assert_eq!(encode_property_reference_to_sink(&mut tail, &reference)?, 2);
assert!(tail.is_empty());
assert_eq!(storage, [0x09, 0x55]);