Skip to main content

FakeConn

Struct FakeConn 

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

The server’s end of one connection. Like Rails it keeps the identifiers it has confirmed and ignores a second subscribe for one of them, so a test reads off the wire exactly what a Rails server would act on, in the order the test acts on it.

Implementations§

Source§

impl FakeConn

Source

pub async fn push(&self, frame: &str)

Plays a server frame to the client.

Source

pub async fn welcome(&self)

Plays the welcome that makes the connection usable.

Source

pub async fn confirm(&self, identifier: &str)

Confirms a subscription, and remembers it the way Rails does.

Source

pub async fn reject(&self, identifier: &str)

Turns a subscription down, which also forgets it: the client is free to try again.

Source

pub async fn broadcast(&self, identifier: &str, message: &str)

Plays a channel message to the client, as the server broadcasts one to identifier.

Source

pub fn fail_writes(&self)

Every write from now on fails, the way a socket the peer has stopped reading does once the write timeout passes.

Source

pub async fn writing(&self, count: usize)

Waits until count writes have begun. With a write buffer smaller than that, the last of them is still waiting for the test to read what came before it.

Source

pub async fn sent(&self) -> Vec<u8> ⓘ

The next payload the client wrote that the server acts on, exactly as it went out.

Source

pub async fn command(&self) -> SentCommand

The next command the client sent, decoded.

Source

pub async fn expect_command(&self, name: &str, identifier: &str) -> SentCommand

The next command, which has to be the one named. Taking a subscribe is not answering it: until confirm, the server is as good as having dropped it on the floor and the client’s guarantor will send it again.

Source

pub async fn expect_silence(&self)

Fails when the client sends anything in the next little while.

Source

pub fn close(&self)

Hangs up from the server’s side.

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more