Skip to main content

rustbac_core/services/
mod.rs

1pub mod acknowledge_alarm;
2pub mod alarm_summary;
3pub mod atomic_read_file;
4pub mod atomic_write_file;
5pub mod cov_notification;
6pub mod device_management;
7pub mod enrollment_summary;
8pub mod event_information;
9pub mod event_notification;
10pub mod i_am;
11pub mod list_element;
12pub mod object_management;
13pub mod private_transfer;
14pub mod read_property;
15pub mod read_property_multiple;
16pub mod read_range;
17pub mod subscribe_cov;
18pub mod subscribe_cov_property;
19pub mod time_synchronization;
20pub mod value_codec;
21pub mod who_has;
22pub mod who_is;
23pub mod write_property;
24pub mod write_property_multiple;
25
26#[cfg(feature = "alloc")]
27use crate::encoding::{primitives::decode_unsigned, reader::Reader, tag::Tag};
28#[cfg(feature = "alloc")]
29use crate::types::ObjectId;
30#[cfg(feature = "alloc")]
31use crate::DecodeError;
32
33/// Decode a required context-tagged unsigned integer at the expected tag number.
34#[cfg(feature = "alloc")]
35pub(crate) fn decode_required_ctx_unsigned(
36    r: &mut Reader<'_>,
37    expected_tag_num: u8,
38) -> Result<u32, DecodeError> {
39    match Tag::decode(r)? {
40        Tag::Context { tag_num, len } if tag_num == expected_tag_num => {
41            decode_unsigned(r, len as usize)
42        }
43        _ => Err(DecodeError::InvalidTag),
44    }
45}
46
47/// Decode a required context-tagged BACnet object identifier at the expected tag number.
48#[cfg(feature = "alloc")]
49pub(crate) fn decode_required_ctx_object_id(
50    r: &mut Reader<'_>,
51    expected_tag_num: u8,
52) -> Result<ObjectId, DecodeError> {
53    Ok(ObjectId::from_raw(decode_required_ctx_unsigned(
54        r,
55        expected_tag_num,
56    )?))
57}