Skip to main content

DeviceIdentity

Struct DeviceIdentity 

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn with_name(self, name: impl Into<String>) -> DeviceIdentity

Overrides the Device object name (defaults to device-{instance}).

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn instance(&self) -> u32

Device instance number.

Source

pub fn vendor_id(&self) -> u16

Vendor identifier (I-Am + Device VENDOR_IDENTIFIER).

Source

pub fn max_apdu_length(&self) -> u16

Raw requested or resolved local receive ceiling.

Source

pub fn name(&self) -> &str

Device object name.

Source

pub fn apdu_segment_timeout_ms(&self) -> u64

Segment timeout in milliseconds. The shared default is 5000 ms.

Source

pub fn resolve( &self, local_receive_capacity: u16, ) -> Result<DeviceIdentity, Error>

Resolve the requested receive ceiling before any transport I/O.

Source

pub fn validate(&self) -> Result<(), Error>

Check the pure Device declaration. Executors also validate deadlines.

Source

pub fn validate_device(&self, device: &dyn BACnetObject) -> Result<(), Error>

Validate a supplied Device without rebuilding it or changing its state.

Source

pub fn segmentation(&self) -> Segmentation

Segmentation support (I-Am + Device SEGMENTATION_SUPPORTED).

Source

pub fn services(&self) -> &[ServiceSupported]

Services profile (Device PROTOCOL_SERVICES_SUPPORTED; no superset).

Source

pub fn network_ports(&self) -> &[NetworkPortEntry]

Configured Network-Port entries, independent of live transport binding.

Source

pub fn device_uuid(&self) -> [u8; 16]

Durable caller-owned SC device UUID.

Source

pub fn device_oid(&self) -> ObjectIdentifier

Device object identifier derived from the instance.

Source

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

Source§

fn clone(&self) -> DeviceIdentity

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 DeviceIdentity

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for DeviceIdentity

Source§

fn default() -> DeviceIdentity

Returns the “default value” for a type. 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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more