pub struct ObjectDatabase { /* private fields */ }Expand description
A collection of BACnet objects, keyed by ObjectIdentifier.
Enforces Object_Name uniqueness within a device. Maintains secondary indexes for O(1) name lookup and O(1) type lookup.
Implementations§
Source§impl ObjectDatabase
impl ObjectDatabase
Sourcepub fn add(&mut self, object: Box<dyn BACnetObject>) -> Result<(), Error>
pub fn add(&mut self, object: Box<dyn BACnetObject>) -> Result<(), Error>
Add an object to the database.
Returns Err if another object already has the same object_name().
Replacing an object with the same OID is allowed (the old object is removed).
Sourcepub fn find_by_name(&self, name: &str) -> Option<&dyn BACnetObject>
pub fn find_by_name(&self, name: &str) -> Option<&dyn BACnetObject>
Look up an object by its name. O(1) via the name index.
Sourcepub fn check_name_available(
&self,
oid: &ObjectIdentifier,
new_name: &str,
) -> Result<(), Error>
pub fn check_name_available( &self, oid: &ObjectIdentifier, new_name: &str, ) -> Result<(), Error>
Check whether new_name is available for object oid.
Returns Ok(()) if the name is unused or already belongs to oid.
Returns Err(DUPLICATE_NAME) if another object owns the name.
Sourcepub fn update_name_index(&mut self, oid: &ObjectIdentifier)
pub fn update_name_index(&mut self, oid: &ObjectIdentifier)
Update the name index after a successful Object_Name write.
Call this after write_property(OBJECT_NAME, …) succeeds.
Sourcepub fn get(&self, oid: &ObjectIdentifier) -> Option<&dyn BACnetObject>
pub fn get(&self, oid: &ObjectIdentifier) -> Option<&dyn BACnetObject>
Get a shared reference to an object by identifier.
Sourcepub fn get_mut(
&mut self,
oid: &ObjectIdentifier,
) -> Option<&mut Box<dyn BACnetObject>>
pub fn get_mut( &mut self, oid: &ObjectIdentifier, ) -> Option<&mut Box<dyn BACnetObject>>
Get a mutable reference to an object by identifier.
Sourcepub fn enrollment_eval_state_invalidated(&self, oid: &ObjectIdentifier) -> bool
pub fn enrollment_eval_state_invalidated(&self, oid: &ObjectIdentifier) -> bool
Whether an Event Enrollment object’s private evaluator state requires a successful reset before reuse.
Sourcepub fn set_enrollment_eval_state_invalidated(
&mut self,
oid: ObjectIdentifier,
invalidated: bool,
)
pub fn set_enrollment_eval_state_invalidated( &mut self, oid: ObjectIdentifier, invalidated: bool, )
Mark or clear the reset requirement for Event Enrollment private state.
Sourcepub fn enrollment_eval_source(
&self,
oid: &ObjectIdentifier,
) -> Option<EventEnrollmentMonitoredSource>
pub fn enrollment_eval_source( &self, oid: &ObjectIdentifier, ) -> Option<EventEnrollmentMonitoredSource>
Return database-owned monitored-source state for a custom Event Enrollment object.
Sourcepub fn set_enrollment_eval_source(
&mut self,
oid: ObjectIdentifier,
source: Option<EventEnrollmentMonitoredSource>,
)
pub fn set_enrollment_eval_source( &mut self, oid: ObjectIdentifier, source: Option<EventEnrollmentMonitoredSource>, )
Store database-owned monitored-source state for a custom Event Enrollment object.
Sourcepub fn remove(
&mut self,
oid: &ObjectIdentifier,
) -> Option<Box<dyn BACnetObject>>
pub fn remove( &mut self, oid: &ObjectIdentifier, ) -> Option<Box<dyn BACnetObject>>
Remove an object by identifier.
Sourcepub fn list_objects(&self) -> Vec<ObjectIdentifier>
pub fn list_objects(&self) -> Vec<ObjectIdentifier>
List all object identifiers in the database.
Sourcepub fn find_by_type(&self, object_type: ObjectType) -> Vec<ObjectIdentifier>
pub fn find_by_type(&self, object_type: ObjectType) -> Vec<ObjectIdentifier>
Find all objects of a given type.
Returns a Vec of ObjectIdentifiers whose object type matches object_type.
Useful for WhoHas, object enumeration, and similar queries.
Sourcepub fn iter_objects(
&self,
) -> impl Iterator<Item = (ObjectIdentifier, &dyn BACnetObject)>
pub fn iter_objects( &self, ) -> impl Iterator<Item = (ObjectIdentifier, &dyn BACnetObject)>
Iterate over all (ObjectIdentifier, &dyn BACnetObject) pairs.
Avoids the double-lookup pattern of list_objects() followed by get().
Sourcepub fn set_clock_reader(&mut self, clock: Option<Arc<dyn ClockReader>>)
pub fn set_clock_reader(&mut self, clock: Option<Arc<dyn ClockReader>>)
Bind one clock reader to the database and every object it contains.
Devices added after this call receive the same reader in add.
Sourcepub fn clock_frame(&self) -> Option<ClockFrame>
pub fn clock_frame(&self) -> Option<ClockFrame>
Read one coherent sample from the database’s shared clock.
Sourcepub fn for_each_object_mut<F>(&mut self, f: F)
pub fn for_each_object_mut<F>(&mut self, f: F)
Visit every (ObjectIdentifier, &mut dyn BACnetObject) pair.
Mutable counterpart to iter_objects, used by
the intrinsic-reporting tick task to advance pending transitions. A
callback is used (rather than a returned impl Iterator) so the
&mut dyn BACnetObject borrow is tied to this call’s lifetime.