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>
impl<'a> Node<'a>
Sourcepub fn endpoint(&self, id: EndpointId) -> Option<&'a Endpoint<'a>>
pub fn endpoint(&self, id: EndpointId) -> Option<&'a Endpoint<'a>>
The endpoint with this id.
Sourcepub fn cluster(
&self,
endpoint: EndpointId,
cluster: ClusterId,
) -> Option<&'a ClusterDescriptor<'a>>
pub fn cluster( &self, endpoint: EndpointId, cluster: ClusterId, ) -> Option<&'a ClusterDescriptor<'a>>
The cluster at an endpoint.
Sourcepub fn validate(&self) -> Result<(), Malformed>
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.
Sourcepub fn expand(&self, path: &AttributePath) -> Expand<'a> ⓘ
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.
Sourcepub fn expand_from(
&self,
path: &AttributePath,
cursor: ExpandCursor,
) -> Expand<'a> ⓘ
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.
Sourcepub fn resolve(
&self,
endpoint: EndpointId,
cluster: ClusterId,
attribute: AttributeId,
) -> Result<Resolved<'a>, Missing>
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>
impl<'a> Node<'a>
Sourcepub fn resolve_event(
&self,
endpoint: EndpointId,
cluster: ClusterId,
event: EventId,
) -> Result<ResolvedEvent<'a>, Missing>
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.
Sourcepub fn resolve_command(
&self,
endpoint: EndpointId,
cluster: ClusterId,
command: CommandId,
) -> Result<ResolvedCommand<'a>, MissingCommand>
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).
Sourcepub fn expand_commands(&self, path: &CommandPath) -> ExpandCommands<'a> ⓘ
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.