pub struct MockHandler<R: RoleId> { /* private fields */ }Expand description
A mock handler that records operations and provides scripted responses
Implementations§
Source§impl<R: RoleId> MockHandler<R>
impl<R: RoleId> MockHandler<R>
pub fn new(role: R) -> Self
pub fn add_response(&mut self, response: MockResponse<<R as RoleId>::Label>)
pub fn operations(&self) -> &[MockOperation<R>]
pub fn clear_operations(&mut self)
Trait Implementations§
Source§impl<R: RoleId + 'static> ChoreoHandler for MockHandler<R>
impl<R: RoleId + 'static> ChoreoHandler for MockHandler<R>
Source§fn send<'life0, 'life1, 'life2, 'async_trait, M>(
&'life0 mut self,
_ep: &'life1 mut Self::Endpoint,
to: Self::Role,
_msg: &'life2 M,
) -> Pin<Box<dyn Future<Output = ChoreoResult<()>> + Send + 'async_trait>>
fn send<'life0, 'life1, 'life2, 'async_trait, M>( &'life0 mut self, _ep: &'life1 mut Self::Endpoint, to: Self::Role, _msg: &'life2 M, ) -> Pin<Box<dyn Future<Output = ChoreoResult<()>> + Send + 'async_trait>>
Send a message to a specific role Read more
Source§fn recv<'life0, 'life1, 'async_trait, M>(
&'life0 mut self,
_ep: &'life1 mut Self::Endpoint,
from: Self::Role,
) -> Pin<Box<dyn Future<Output = ChoreoResult<M>> + Send + 'async_trait>>where
M: 'async_trait + DeserializeOwned + Send,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn recv<'life0, 'life1, 'async_trait, M>(
&'life0 mut self,
_ep: &'life1 mut Self::Endpoint,
from: Self::Role,
) -> Pin<Box<dyn Future<Output = ChoreoResult<M>> + Send + 'async_trait>>where
M: 'async_trait + DeserializeOwned + Send,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Receive a strongly-typed message from a specific role Read more
Source§fn choose<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ep: &'life1 mut Self::Endpoint,
at: Self::Role,
label: <Self::Role as RoleId>::Label,
) -> Pin<Box<dyn Future<Output = ChoreoResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn choose<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ep: &'life1 mut Self::Endpoint,
at: Self::Role,
label: <Self::Role as RoleId>::Label,
) -> Pin<Box<dyn Future<Output = ChoreoResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Internal choice: broadcast a label selection Read more
Source§fn offer<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ep: &'life1 mut Self::Endpoint,
from: Self::Role,
) -> Pin<Box<dyn Future<Output = ChoreoResult<<Self::Role as RoleId>::Label>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn offer<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ep: &'life1 mut Self::Endpoint,
from: Self::Role,
) -> Pin<Box<dyn Future<Output = ChoreoResult<<Self::Role as RoleId>::Label>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
External choice: receive a label selection Read more
Source§fn with_timeout<'life0, 'life1, 'async_trait, F, T>(
&'life0 mut self,
_ep: &'life1 mut Self::Endpoint,
_at: Self::Role,
_dur: Duration,
body: F,
) -> Pin<Box<dyn Future<Output = ChoreoResult<T>> + Send + 'async_trait>>where
F: Future<Output = ChoreoResult<T>> + Send + 'async_trait,
T: 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn with_timeout<'life0, 'life1, 'async_trait, F, T>(
&'life0 mut self,
_ep: &'life1 mut Self::Endpoint,
_at: Self::Role,
_dur: Duration,
body: F,
) -> Pin<Box<dyn Future<Output = ChoreoResult<T>> + Send + 'async_trait>>where
F: Future<Output = ChoreoResult<T>> + Send + 'async_trait,
T: 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Execute a future with a timeout Read more
Source§fn broadcast<'life0, 'life1, 'life2, 'life3, 'async_trait, M>(
&'life0 mut self,
ep: &'life1 mut Self::Endpoint,
recipients: &'life2 [Self::Role],
msg: &'life3 M,
) -> Pin<Box<dyn Future<Output = ChoreoResult<()>> + Send + 'async_trait>>
fn broadcast<'life0, 'life1, 'life2, 'life3, 'async_trait, M>( &'life0 mut self, ep: &'life1 mut Self::Endpoint, recipients: &'life2 [Self::Role], msg: &'life3 M, ) -> Pin<Box<dyn Future<Output = ChoreoResult<()>> + Send + 'async_trait>>
Broadcast a message to multiple recipients Read more
Source§impl<R: RoleId> DocumentedHandlerContract for MockHandler<R>
impl<R: RoleId> DocumentedHandlerContract for MockHandler<R>
Auto Trait Implementations§
impl<R> Freeze for MockHandler<R>where
R: Freeze,
impl<R> RefUnwindSafe for MockHandler<R>
impl<R> Send for MockHandler<R>
impl<R> Sync for MockHandler<R>
impl<R> Unpin for MockHandler<R>
impl<R> UnsafeUnpin for MockHandler<R>where
R: UnsafeUnpin,
impl<R> UnwindSafe for MockHandler<R>
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
Mutably borrows from an owned value. Read more
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
Source§impl<T> ChoreoHandlerExt for Twhere
T: ChoreoHandler,
impl<T> ChoreoHandlerExt for Twhere
T: ChoreoHandler,
Source§fn run_program<'life0, 'life1, 'async_trait, M>(
&'life0 mut self,
endpoint: &'life1 mut Self::Endpoint,
program: Program<Self::Role, M>,
) -> Pin<Box<dyn Future<Output = ChoreoResult<InterpretResult<M>>> + Send + 'async_trait>>where
M: ProgramMessage + Serialize + DeserializeOwned + 'static + 'async_trait,
Self: Send + Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn run_program<'life0, 'life1, 'async_trait, M>(
&'life0 mut self,
endpoint: &'life1 mut Self::Endpoint,
program: Program<Self::Role, M>,
) -> Pin<Box<dyn Future<Output = ChoreoResult<InterpretResult<M>>> + Send + 'async_trait>>where
M: ProgramMessage + Serialize + DeserializeOwned + 'static + 'async_trait,
Self: Send + Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Run a choreographic program using this handler
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
Source§fn lossless_try_into(self) -> Option<Dst>
fn lossless_try_into(self) -> Option<Dst>
Performs the conversion.
Source§impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
Source§fn lossy_into(self) -> Dst
fn lossy_into(self) -> Dst
Performs the conversion.
Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Casts the value.
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> StrictAs for T
impl<T> StrictAs for T
Source§fn strict_as<Dst>(self) -> Dstwhere
T: StrictCast<Dst>,
fn strict_as<Dst>(self) -> Dstwhere
T: StrictCast<Dst>,
Casts the value.
Source§impl<Src, Dst> StrictCastFrom<Src> for Dstwhere
Src: StrictCast<Dst>,
impl<Src, Dst> StrictCastFrom<Src> for Dstwhere
Src: StrictCast<Dst>,
Source§fn strict_cast_from(src: Src) -> Dst
fn strict_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
Source§fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
Source§fn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Source§impl<T> WrappingAs for T
impl<T> WrappingAs for T
Source§fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
Source§fn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.