Skip to main content

Node

Struct Node 

Source
pub struct Node<'a> {
    pub endpoints: &'a [Endpoint<'a>],
}
Expand description

A node’s data model: its endpoints and everything on them.

Fields§

§endpoints: &'a [Endpoint<'a>]

The endpoints, sorted by id.

Implementations§

Source§

impl<'a> Node<'a>

Source

pub const fn new(endpoints: &'a [Endpoint<'a>]) -> Self

A node over a slice of endpoints.

Source

pub fn endpoint(&self, id: EndpointId) -> Option<&'a Endpoint<'a>>

The endpoint with this id.

Source

pub fn cluster( &self, endpoint: EndpointId, cluster: ClusterId, ) -> Option<&'a ClusterDescriptor<'a>>

The cluster at an endpoint.

Source

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

Checks every ordering invariant the lookups depend on.

Everything here binary-searches, so an unsorted slice does not fail loudly — it silently fails to find things, which on a device looks like a cluster that is simply not there. const slices cannot be checked by the compiler today, so this is called once at start-up instead.

Source

pub fn expand(&self, path: &AttributePath) -> Expand<'a> ⓘ

Expands a request path into every existent path it names (§8.2.1.6).

No access check happens here. §8.2.1.6: “This process does not check access qualities, such as read or write access, privileges, or fabric qualities.” The caller applies those, and §8.4.3.2 decides what to do when one fails — which differs between a concrete path and an expanded one.

A concrete path that does not exist yields nothing; the caller must notice that and produce the right status, which is why Node::resolve exists beside this.

Source

pub fn expand_from( &self, path: &AttributePath, cursor: ExpandCursor, ) -> Expand<'a> ⓘ

The same expansion, resumed at cursor.

Core §10.2.3 splits a report “into multiple messages at logical boundaries due to the size limitations imposed by IPv6 for UDP packets”, and each message after the first has to start where the last one stopped. A cursor from Expand::cursor is that place.

Source

pub fn resolve( &self, endpoint: EndpointId, cluster: ClusterId, attribute: AttributeId, ) -> Result<Resolved<'a>, Missing>

Resolves a concrete path, saying precisely which part of it does not exist.

§8.4.3.2 requires a distinct status for each level — UNSUPPORTED_ENDPOINT, UNSUPPORTED_CLUSTER, UNSUPPORTED_ATTRIBUTE — so “not found” is not a good enough answer: a client uses the difference to tell a missing endpoint from a missing feature on one that is there.

Source§

impl<'a> Node<'a>

Source

pub fn resolve_event( &self, endpoint: EndpointId, cluster: ClusterId, event: EventId, ) -> Result<ResolvedEvent<'a>, Missing>

Resolves a concrete event path, the way Node::resolve does an attribute.

§8.4.3.3’s event paths are validated exactly like attribute paths: the endpoint, then the cluster, then the event — each level a different answer, because a client that asked for an endpoint this node does not have has made a different mistake from one that asked for an event the cluster does not define.

Source

pub fn resolve_command( &self, endpoint: EndpointId, cluster: ClusterId, command: CommandId, ) -> Result<ResolvedCommand<'a>, MissingCommand>

Resolves a concrete command path, saying which level is missing (§8.8.2.3 step b.ii).

Source

pub fn expand_commands(&self, path: &CommandPath) -> ExpandCommands<'a> ⓘ

Expands a command path into every existent command it names (§8.2.1.6).

§8.8 permits a wildcard here — “Invoke Request action SHALL support group paths and SHOULD support wildcard paths” — but only when the request carries exactly one command; §8.8.2.2 step 5a requires every path to be concrete once there are several.

Trait Implementations§

Source§

impl<'a> Clone for Node<'a>

Source§

fn clone(&self) -> Self

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<'a> Copy for Node<'a>

Source§

impl<'a> Debug for Node<'a>

Source§

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

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

impl<'a> Eq for Node<'a>

Source§

impl<'a> PartialEq for Node<'a>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> StructuralPartialEq for Node<'a>

Auto Trait Implementations§

§

impl<'a> Forget for Node<'a>

§

impl<'a> Freeze for Node<'a>

§

impl<'a> Move for Node<'a>

§

impl<'a> RefUnwindSafe for Node<'a>

§

impl<'a> Send for Node<'a>

§

impl<'a> Sync for Node<'a>

§

impl<'a> Unpin for Node<'a>

§

impl<'a> UnsafeUnpin for Node<'a>

§

impl<'a> UnwindSafe for Node<'a>

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