Broker

Struct Broker 

Source
pub struct Broker {
    pub(crate) listener: TcpListener,
}
Expand description

A TCP listener that hands out scripted MQTT connections.

Fields§

§listener: TcpListener

Implementations§

Source§

impl Broker

Source

pub async fn bind() -> Self

Binds to an ephemeral IPv6 port.

Listening on [::] accepts IPv6 clients and, on the usual dual-stack configuration, IPv4-mapped clients (e.g. 127.0.0.1) too. On a rare IPv6-only host, clients simply connect over IPv6.

§Panics

Panics if binding fails.

Source

pub fn port(&self) -> u16

The TCP port the fake broker is listening on.

§Panics

Panics if the listener’s local address cannot be queried.

Source

pub fn host(&self) -> &'static str

The loopback host a client should connect to, matching the bound address family. Pair it with port so test code never has to assume IPv4 or dual-stack.

Source

pub async fn accept(&self) -> Conn

Accepts the next client connection.

§Panics

Panics if no client connects within 10 s.

Source

pub async fn try_accept(&self, dur: Duration) -> Option<Conn>

Accepts the next client connection, returning None if no client connects within dur.

§Panics

Panics on listener I/O errors.

Auto Trait Implementations§

§

impl !Freeze for Broker

§

impl RefUnwindSafe for Broker

§

impl Send for Broker

§

impl Sync for Broker

§

impl Unpin for Broker

§

impl UnwindSafe for Broker

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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.