pub struct Responder<'a, T> { /* private fields */ }Expand description
A generic responder utility for accepting and handling exchanges received by the provided Matter stack,
by applying the provided ExchangeHandler instance to each accepted exchange.
This responder uses an intra-task concurrency model - without an external executor - where all handling is done as a single future.
Implementations§
Source§impl<'a, T> Responder<'a, T>where
T: ExchangeHandler,
impl<'a, T> Responder<'a, T>where
T: ExchangeHandler,
Sourcepub const fn new(
name: &'a str,
handler: T,
matter: &'a Matter<'a>,
respond_after_ms: u32,
) -> Responder<'a, T>
pub const fn new( name: &'a str, handler: T, matter: &'a Matter<'a>, respond_after_ms: u32, ) -> Responder<'a, T>
Create a new responder.
The respond_after_ms parameter instructs the responder how much time to wait before accepting an exchange.
This is useful when utilizing multiple responders on a single Matter instance, where e.g. the first (main) responder is the actual one,
responsible for handling the incoming exchanges, while e.g. another one - with a non-zero respond_after_ms - is answerring all exchanges
not accepted in time by the main responder with a simple “I’m busy, try again later” handling.
Sourcepub fn handler(&self) -> &T
pub fn handler(&self) -> &T
Get a reference to the ExchangeHandler instance used by this responder
Sourcepub async fn run<const N: usize>(&self) -> Result<(), Error>
pub async fn run<const N: usize>(&self) -> Result<(), Error>
Run the responder with a given number of handlers.
Source§impl<'d, 'a, C, B, T, K, N, NC, const NS: usize, const NE: usize> Responder<'a, ChainedExchangeHandler<&'d InteractionModel<'a, C, B, T, K, N, NC, NS, NE>, SecureChannel<'d, &'d C>>>
impl<'d, 'a, C, B, T, K, N, NC, const NS: usize, const NE: usize> Responder<'a, ChainedExchangeHandler<&'d InteractionModel<'a, C, B, T, K, N, NC, NS, NE>, SecureChannel<'d, &'d C>>>
Sourcepub const fn new_default(
data_model: &'d InteractionModel<'a, C, B, T, K, N, NC, NS, NE>,
) -> Responder<'a, ChainedExchangeHandler<&'d InteractionModel<'a, C, B, T, K, N, NC, NS, NE>, SecureChannel<'d, &'d C>>>
pub const fn new_default( data_model: &'d InteractionModel<'a, C, B, T, K, N, NC, NS, NE>, ) -> Responder<'a, ChainedExchangeHandler<&'d InteractionModel<'a, C, B, T, K, N, NC, NS, NE>, SecureChannel<'d, &'d C>>>
Creates a “default” responder. This is a responder that composes and uses the rs-matter-provided ExchangeHandler implementations
(SecureChannel and InteractionModel) for handling the Secure Channel protocol and the Interaction Model protocol.
Source§impl<'a> Responder<'a, ChainedExchangeHandler<BusyInteractionModel, BusySecureChannel>>
impl<'a> Responder<'a, ChainedExchangeHandler<BusyInteractionModel, BusySecureChannel>>
Sourcepub const fn new_busy(
matter: &'a Matter<'a>,
respond_after_ms: u32,
) -> Responder<'a, ChainedExchangeHandler<BusyInteractionModel, BusySecureChannel>>
pub const fn new_busy( matter: &'a Matter<'a>, respond_after_ms: u32, ) -> Responder<'a, ChainedExchangeHandler<BusyInteractionModel, BusySecureChannel>>
Creates a simple “busy” responder, which is answering all exchanges with a simple “I’m busy, try again later” handling.
The resonder is using the rs-matter-provided ExchangeHandler instances (BusySecureChannel and BusyInteractionModel)
capable of answering with “busy” messages the SC and IM protocols, respectively.
Exchanges which are not accepted after the specified milliseconds are answered by this responder, as the assumption is that the main responder is busy and cannot answer these right now.
Auto Trait Implementations§
impl<'a, T> !RefUnwindSafe for Responder<'a, T>
impl<'a, T> !Send for Responder<'a, T>
impl<'a, T> !Sync for Responder<'a, T>
impl<'a, T> !UnwindSafe for Responder<'a, T>
impl<'a, T> Freeze for Responder<'a, T>where
T: Freeze,
impl<'a, T> Unpin for Responder<'a, T>where
T: Unpin,
impl<'a, T> UnsafeUnpin for Responder<'a, T>where
T: UnsafeUnpin,
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