Skip to main content

DeviceObject

Struct DeviceObject 

Source
pub struct DeviceObject { /* private fields */ }
Expand description

Device Object that manages all object types and instances

The Device Object maintains a registry of object function handlers and provides centralized dispatch for all object operations.

Implementations§

Source§

impl DeviceObject

Source

pub fn new(device_instance: u32, device_name: String) -> Self

Create a new Device Object

§Arguments
  • device_instance - The device instance number (0-4194302)
  • device_name - The name of this device
§Example
let device = DeviceObject::new(12345, "BACnet Device".to_string());
Source

pub fn find_object_functions( &self, object_type: ObjectType, ) -> Option<&ObjectFunctions>

Find object functions for a specific object type

Returns a reference to the ObjectFunctions for the specified type, or None if no handler is registered for that type.

This mirrors the C reference implementation’s Device_Object_Functions_Find()

§Example
if let Some(funcs) = device.find_object_functions(ObjectType::AnalogInput) {
    let count = (funcs.count)();
    println!("Found {} analog inputs", count);
}
Source

pub fn object_functions(&self) -> &[ObjectFunctions]

Get the entire object function table

Returns a slice containing all registered object function handlers.

This mirrors the C reference implementation’s Device_Object_Functions()

§Example
for funcs in device.object_functions() {
    let count = (funcs.count)();
    println!("{:?}: {} instances", funcs.object_type, count);
}
Source

pub fn register_object_functions(&mut self, functions: ObjectFunctions)

Register object functions for a specific object type

Adds or replaces the object function handler for the specified type. This allows for custom object implementations and overriding default behavior.

§Arguments
  • functions - The object function handlers to register
§Example
// Register custom Analog Input implementation
device.register_object_functions(ObjectFunctions {
    object_type: ObjectType::AnalogInput,
    count: my_ai_count,
    index_to_instance: my_ai_index,
    valid_instance: my_ai_valid,
    object_name: my_ai_name,
    read_property: my_ai_read,
    write_property: my_ai_write,
    is_property_writable: my_ai_writable,
    property_list: my_ai_props,
});
Source

pub fn device_instance(&self) -> u32

Get the device instance number

Source

pub fn device_name(&self) -> &str

Get the device name

Source

pub fn device_identifier(&self) -> &str

Get the device identifier string

Source

pub fn application_software_version(&self) -> &str

Get the application software version

Source

pub fn protocol_version(&self) -> u8

Get the protocol version

Source

pub fn protocol_revision(&self) -> u8

Get the protocol revision

Source

pub fn set_device_description(&mut self, description: String)

Set the device description

Source

pub fn set_vendor_info(&mut self, vendor_id: u16, vendor_name: String)

Set vendor information

Source

pub fn set_model_info(&mut self, model_name: String, firmware_revision: String)

Set model information

Source

pub fn read_object_property( &self, object_id: ObjectIdentifier, property: PropertyIdentifier, ) -> Result<PropertyValue>

Read a property from any object managed by this device

§Arguments
  • object_id - The object identifier (type + instance)
  • property - The property identifier
§Returns

The property value, or an error if the object or property is not found

Source

pub fn write_object_property( &self, object_id: ObjectIdentifier, property: PropertyIdentifier, value: PropertyValue, ) -> Result<()>

Write a property to any object managed by this device

§Arguments
  • object_id - The object identifier (type + instance)
  • property - The property identifier
  • value - The value to write
§Returns

Ok(()) on success, or an error if the object, property is not found or not writable

Source

pub fn total_object_count(&self) -> usize

Get the total object count across all types

Trait Implementations§

Source§

impl Clone for DeviceObject

Source§

fn clone(&self) -> DeviceObject

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DeviceObject

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.