pub struct DeviceIdentity { /* private fields */ }Expand description
Single Device identity source.
Owns the Device declarations shared by a server and an endpoint. Resolve the requested receive ceiling against the owned transport before generating a stock Device or validating a supplied one. Services and Network Ports are configuration data; each executor controls its served service profile.
use bacnet_objects::device_identity::DeviceIdentity;
let identity = DeviceIdentity::new(1001, 42)?;
assert_eq!(identity.instance(), 1001);
assert_eq!(identity.vendor_id(), 42);Implementations§
Source§impl DeviceIdentity
impl DeviceIdentity
Sourcepub fn new(instance: u32, vendor_id: u16) -> Result<DeviceIdentity, Error>
pub fn new(instance: u32, vendor_id: u16) -> Result<DeviceIdentity, Error>
Creates an identity with endpoint-composed defaults.
Defaults: max_apdu = 1476, segmentation = NONE,
services = [READ_PROPERTY] (narrow endpoint reality, no superset),
no ports, zero UUID (B/IP-only may keep zeros; SC dial requires
with_device_uuid). Returns
Error::Encoding for an
out-of-range Device instance.
Sourcepub fn with_max_apdu(self, max_apdu: u16) -> Result<DeviceIdentity, Error>
pub fn with_max_apdu(self, max_apdu: u16) -> Result<DeviceIdentity, Error>
Sets the raw requested receive ceiling (at least 50 bytes).
Discovery and Device reads preserve this raw value, including 1474. Confirmed-Request header encoders floor it separately. Startup resolves it against the owned transport’s stable local receive capacity.
Sourcepub fn with_segmentation(self, segmentation: Segmentation) -> DeviceIdentity
pub fn with_segmentation(self, segmentation: Segmentation) -> DeviceIdentity
Overrides segmentation support for a matching full server.
Narrow EndpointSession roles require NONE and reject any other identity before ingress starts. A full server uses this declaration with the segment timeout supplied by this identity.
Sourcepub fn with_apdu_segment_timeout_ms(self, timeout_ms: u64) -> DeviceIdentity
pub fn with_apdu_segment_timeout_ms(self, timeout_ms: u64) -> DeviceIdentity
Sets the Device and full-server segment timeout. EndpointSession roles require segmentation NONE; client timers remain caller-owned.
Sourcepub fn with_services(self, services: &[ServiceSupported]) -> DeviceIdentity
pub fn with_services(self, services: &[ServiceSupported]) -> DeviceIdentity
Overrides the services profile (must equal what roles can do; no superset).
Default [READ_PROPERTY] matches the narrow endpoint responder.
EndpointSession::with_device_writes adds WRITE_PROPERTY and
EndpointSession::with_reinitialize adds REINITIALIZE_DEVICE; other
service bits are rejected. Server-role startup also rejects missing
ReadProperty or unsupported bits with neither opt-in, before ingress starts.
ClientOnly has no responder and retains this as a local declaration.
Broader executing profiles require a matching full server.
Sourcepub fn with_device_uuid(self, uuid: [u8; 16]) -> DeviceIdentity
pub fn with_device_uuid(self, uuid: [u8; 16]) -> DeviceIdentity
Stores the durable caller-owned SC device UUID (no generation/storage).
The caller provisions 16 bytes durably and reuses them for the device lifetime. SC hub-dial rejects all-zero; B/IP-only identities may keep zeros.
Sourcepub fn with_name(self, name: impl Into<String>) -> DeviceIdentity
pub fn with_name(self, name: impl Into<String>) -> DeviceIdentity
Overrides the Device object name (defaults to device-{instance}).
Sourcepub fn with_network_port(
self,
entry: NetworkPortEntry,
) -> Result<DeviceIdentity, Error>
pub fn with_network_port( self, entry: NetworkPortEntry, ) -> Result<DeviceIdentity, Error>
Adds one validated configured Network-Port entry.
Rejects duplicate instances and out-of-range Network-Port instances
and invalid profile configuration.
Prefer with_bip_port,
with_bip6_port or
with_sc_port, which encode the population rule.
Sourcepub fn with_bip_port(
self,
instance: u32,
network_number: u32,
ip: Ipv4Addr,
udp_port: u16,
) -> Result<DeviceIdentity, Error>
pub fn with_bip_port( self, instance: u32, network_number: u32, ip: Ipv4Addr, udp_port: u16, ) -> Result<DeviceIdentity, Error>
Adds a B/IP port entry with configured IP/UDP values, including UDP zero.
Sourcepub fn with_bip6_port(
self,
instance: u32,
network_number: u32,
ip: Ipv6Addr,
udp_port: u16,
) -> Result<DeviceIdentity, Error>
pub fn with_bip6_port( self, instance: u32, network_number: u32, ip: Ipv6Addr, udp_port: u16, ) -> Result<DeviceIdentity, Error>
Adds a B/IPv6 port entry with the configured IPv6 address and UDP
port, including UDP zero. See NetworkPortEntry::bip6.
Sourcepub fn with_sc_port(
self,
instance: u32,
network_number: u32,
vmac: [u8; 6],
) -> Result<DeviceIdentity, Error>
pub fn with_sc_port( self, instance: u32, network_number: u32, vmac: [u8; 6], ) -> Result<DeviceIdentity, Error>
Adds an SC port entry keyed by VMAC.
Sourcepub fn max_apdu_length(&self) -> u16
pub fn max_apdu_length(&self) -> u16
Raw requested or resolved local receive ceiling.
Sourcepub fn apdu_segment_timeout_ms(&self) -> u64
pub fn apdu_segment_timeout_ms(&self) -> u64
Segment timeout in milliseconds. The shared default is 5000 ms.
Sourcepub fn resolve(
&self,
local_receive_capacity: u16,
) -> Result<DeviceIdentity, Error>
pub fn resolve( &self, local_receive_capacity: u16, ) -> Result<DeviceIdentity, Error>
Resolve the requested receive ceiling before any transport I/O.
Sourcepub fn validate(&self) -> Result<(), Error>
pub fn validate(&self) -> Result<(), Error>
Check the pure Device declaration. Executors also validate deadlines.
Sourcepub fn validate_device(&self, device: &dyn BACnetObject) -> Result<(), Error>
pub fn validate_device(&self, device: &dyn BACnetObject) -> Result<(), Error>
Validate a supplied Device without rebuilding it or changing its state.
Sourcepub fn segmentation(&self) -> Segmentation
pub fn segmentation(&self) -> Segmentation
Segmentation support (I-Am + Device SEGMENTATION_SUPPORTED).
Sourcepub fn services(&self) -> &[ServiceSupported]
pub fn services(&self) -> &[ServiceSupported]
Services profile (Device PROTOCOL_SERVICES_SUPPORTED; no superset).
Sourcepub fn network_ports(&self) -> &[NetworkPortEntry]
pub fn network_ports(&self) -> &[NetworkPortEntry]
Configured Network-Port entries, independent of live transport binding.
Sourcepub fn device_uuid(&self) -> [u8; 16]
pub fn device_uuid(&self) -> [u8; 16]
Durable caller-owned SC device UUID.
Sourcepub fn device_oid(&self) -> ObjectIdentifier
pub fn device_oid(&self) -> ObjectIdentifier
Device object identifier derived from the instance.
Sourcepub fn build_database(&self) -> Result<ObjectDatabase, Error>
pub fn build_database(&self) -> Result<ObjectDatabase, Error>
Constructs the ObjectDatabase (Device + Network-Port + DEVICE_UUID).
Truth direction: identity -> database. For extra application objects
use build_database_with_extra: it seeds Object_List with
Device + ports + extras upfront so no post-add mutation is needed.
Trait Implementations§
Source§impl Clone for DeviceIdentity
impl Clone for DeviceIdentity
Source§fn clone(&self) -> DeviceIdentity
fn clone(&self) -> DeviceIdentity
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more