Skip to main content

FakeChannel

Struct FakeChannel 

Source
pub struct FakeChannel { /* private fields */ }
Expand description

A Channel for tests: events are injected by the test, sent messages are recorded.

Implementations§

Source§

impl FakeChannel

Source

pub fn new(id: &str, caps: ChannelCaps) -> Self

A channel id (fake:test) with caps.

Source

pub async fn inject(&self, event: InboundEvent)

Waits until the runtime started this channel, then delivers event.

Source

pub fn sent_texts(&self) -> Vec<String>

Texts sent so far, oldest first.

Source

pub fn sent(&self) -> Vec<(ReplyTarget, String)>

Messages sent so far with their targets.

Source

pub fn edits(&self) -> Vec<(String, String)>

Edits so far: (message id, new text).

Source

pub fn typing_count(&self) -> usize

Typing indicators shown so far.

Trait Implementations§

Source§

impl Channel for FakeChannel

Source§

fn id(&self) -> &ChannelId

The configured instance, for example zalo:shop.
Source§

fn caps(&self) -> &ChannelCaps

What the platform supports.
Source§

fn run<'life0, 'async_trait>( &'life0 self, sink: Arc<dyn InboundSink>, shutdown: CancellationToken, ) -> Pin<Box<dyn Future<Output = Result<(), ChannelError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Receives events until shutdown is cancelled, delivering them to sink. Read more
Source§

fn send<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, to: &'life1 ReplyTarget, message: &'life2 RenderedMessage, ) -> Pin<Box<dyn Future<Output = Result<SentRef, ChannelError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Sends one message.
Source§

fn typing<'life0, 'life1, 'async_trait>( &'life0 self, _to: &'life1 ReplyTarget, ) -> Pin<Box<dyn Future<Output = Result<(), ChannelError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Shows a typing indicator once. The runtime repeats it while an agent works.
Source§

fn edit<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, sent: &'life1 SentRef, message: &'life2 RenderedMessage, ) -> Pin<Box<dyn Future<Output = Result<(), ChannelError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Replaces the text of a sent message. Only called when ChannelCaps::edit is true.
Source§

fn webhook(&self) -> Option<Arc<dyn WebhookHandler>>

The webhook endpoint, for platforms that push events over HTTP.
Source§

impl Debug for FakeChannel

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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