Skip to main content

build_database_with_extra

Function build_database_with_extra 

Source
pub fn build_database_with_extra(
    identity: &DeviceIdentity,
    extra: Vec<Box<dyn BACnetObject>>,
) -> Result<ObjectDatabase, Error>
Expand description

Builds a database from an identity plus extra application objects.

Truth direction stays identity-first: the Device Object_List is seeded with Device + ports + every extra OID upfront, so no post-add mutation (and no device/network-port fork) is needed. Extra objects are boxed BACnetObjects (e.g. Analog Input for proofs).

use bacnet_objects::device_identity::{build_database_with_extra, DeviceIdentity};
use bacnet_objects::analog::AnalogInputObject;
use bacnet_types::enums::EngineeringUnits;

let identity = DeviceIdentity::new(1001, 42)?;
let mut point = AnalogInputObject::new(1, "ai-1", EngineeringUnits::NO_UNITS)?;
point.set_present_value(21.5);
let db = build_database_with_extra(&identity, vec![Box::new(point)])?;
assert!(db.get(&identity.device_oid()).is_some());