pub struct CmdDataBuilder<P, const F: usize = 0> { /* private fields */ }Expand description
Streaming builder for one CmdData entry inside the
InvokeRequests array.
Field-state values:
0: nothing written yet1: pastPath2: pastData(struct can be closed)3: pastCommandRef
Implementations§
Source§impl<P> CmdDataBuilder<P>where
P: TLVBuilderParent,
impl<P> CmdDataBuilder<P>where
P: TLVBuilderParent,
Source§impl<P> CmdDataBuilder<P>where
P: TLVBuilderParent,
impl<P> CmdDataBuilder<P>where
P: TLVBuilderParent,
Sourcepub fn path(
self,
endpoint: u16,
cluster: u32,
cmd: u32,
) -> Result<CmdDataBuilder<P, 1>, Error>
pub fn path( self, endpoint: u16, cluster: u32, cmd: u32, ) -> Result<CmdDataBuilder<P, 1>, Error>
Write the concrete (endpoint, cluster, command) path.
Wildcards aren’t meaningful for invokes — every send targets a
concrete (endpoint, cluster, command) triple. The path is
encoded as a list per spec CommandPathIB.
Sourcepub fn path_from(self, path: &CmdPath) -> Result<CmdDataBuilder<P, 1>, Error>
pub fn path_from(self, path: &CmdPath) -> Result<CmdDataBuilder<P, 1>, Error>
Write the path from an existing crate::im::CmdPath. Used
by the snapshot→streaming bridge in ImClient::invoke.
Source§impl<P> CmdDataBuilder<P, 1>where
P: TLVBuilderParent,
impl<P> CmdDataBuilder<P, 1>where
P: TLVBuilderParent,
Sourcepub fn data<F>(self, f: F) -> Result<CmdDataBuilder<P, 2>, Error>
pub fn data<F>(self, f: F) -> Result<CmdDataBuilder<P, 2>, Error>
Write the command request body into the Data slot.
Per Matter Core spec CommandDataIB.Data is the
command’s request payload — any TLV element tagged
TLVTag::Context(1) (= CmdDataTag::Data). For commands
with no request fields (e.g. OnOff::On, OnOff::Toggle)
the data slot is still required: write an empty struct.
Idiomatic call patterns:
// No-payload command (e.g. OnOff::Toggle):
.data(|w| {
w.start_struct(&TLVTag::Context(CmdDataTag::Data as u8))?;
w.end_container()
})?
// Any `T: ToTLV` request body:
.data(|w| req.to_tlv(&TLVTag::Context(CmdDataTag::Data as u8), w))?
// Via a codegen-emitted typed request builder:
.data(|w| MoveToHueRequestBuilder::new(w, ...)?
.hue(180)? .direction(...)? .end())?Sourcepub fn data_builder<B>(self) -> Result<B, Error>where
B: TLVBuilder<CmdDataBuilder<P, 2>>,
pub fn data_builder<B>(self) -> Result<B, Error>where
B: TLVBuilder<CmdDataBuilder<P, 2>>,
Open the Data slot as a typed sub-builder.
Closure-free counterpart to data — hand back
the codegen-emitted request builder for the command, already
opened at CmdDataTag::Data. The caller fills the request
fields, then calls .end() on the sub-builder; that close
writes Data’s closing tag and yields a
CmdDataBuilder<P, 2>. The caller then .end()s once more
to close the CmdData entry struct itself (the “double-end”
pattern of the IM-client glue).
Soundness of the phantom typestate advance: B::new is
contractually required (by TLVBuilder) to open exactly one
container at the supplied tag, and B’s terminal .end()
closes it. So by the time the caller observes the returned
CmdDataBuilder<P, 2>, the Data field has been fully written
and the typestate matches the wire state.
Source§impl<P> CmdDataBuilder<P, 2>where
P: TLVBuilderParent,
impl<P> CmdDataBuilder<P, 2>where
P: TLVBuilderParent,
Sourcepub fn command_ref(self, value: u16) -> Result<CmdDataBuilder<P, 3>, Error>
pub fn command_ref(self, value: u16) -> Result<CmdDataBuilder<P, 3>, Error>
Write the optional CommandRef field. Mandatory when the
InvokeRequests array carries more than one entry (per spec -
the server echoes this back so the client can
correlate responses to requests). For single-command invokes,
omit (go straight to .end()).
Source§impl<P> CmdDataBuilder<P, 2>where
P: TLVBuilderParent,
impl<P> CmdDataBuilder<P, 2>where
P: TLVBuilderParent,
Source§impl<P> CmdDataBuilder<P, 3>where
P: TLVBuilderParent,
impl<P> CmdDataBuilder<P, 3>where
P: TLVBuilderParent,
Trait Implementations§
Source§impl<P> TLVBuilder<P> for CmdDataBuilder<P>where
P: TLVBuilderParent,
impl<P> TLVBuilder<P> for CmdDataBuilder<P>where
P: TLVBuilderParent,
Source§impl<P, const F: usize> TLVBuilderParent for CmdDataBuilder<P, F>where
P: TLVBuilderParent,
impl<P, const F: usize> TLVBuilderParent for CmdDataBuilder<P, F>where
P: TLVBuilderParent,
Source§type Write = <P as TLVBuilderParent>::Write
type Write = <P as TLVBuilderParent>::Write
Source§fn writer(&mut self) -> &mut <CmdDataBuilder<P, F> as TLVBuilderParent>::Write
fn writer(&mut self) -> &mut <CmdDataBuilder<P, F> as TLVBuilderParent>::Write
Auto Trait Implementations§
impl<P, const F: usize> Freeze for CmdDataBuilder<P, F>where
P: Freeze,
impl<P, const F: usize> RefUnwindSafe for CmdDataBuilder<P, F>where
P: RefUnwindSafe,
impl<P, const F: usize> Send for CmdDataBuilder<P, F>where
P: Send,
impl<P, const F: usize> Sync for CmdDataBuilder<P, F>where
P: Sync,
impl<P, const F: usize> Unpin for CmdDataBuilder<P, F>where
P: Unpin,
impl<P, const F: usize> UnsafeUnpin for CmdDataBuilder<P, F>where
P: UnsafeUnpin,
impl<P, const F: usize> UnwindSafe for CmdDataBuilder<P, F>where
P: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more