Struct MqttServer

Source
pub struct MqttServer<Io, St, C: ServiceFactory, U> { /* private fields */ }
Expand description

Mqtt Server

Implementations§

Source§

impl<Io, St, C> MqttServer<Io, St, C, ()>
where St: 'static, C: ServiceFactory<Config = (), Request = Connect<Io>, Response = ConnectAck<Io, St>> + 'static,

Source

pub fn new<F>(connect: F) -> MqttServer<Io, St, C, impl Fn(St, bool)>
where F: IntoServiceFactory<C>,

Create server factory and provide connect service

Source§

impl<Io, St, C, U> MqttServer<Io, St, C, U>
where St: Clone + 'static, U: Fn(St, bool) + 'static, C: ServiceFactory<Config = (), Request = Connect<Io>, Response = ConnectAck<Io, St>> + 'static,

Source

pub fn handshake_timeout(self, timeout: u64) -> Self

Set handshake timeout in millis.

Handshake includes connect packet and response connect-ack. By default handshake timeuot is disabled.

Source

pub fn max_size(self, size: usize) -> Self

Set max inbound frame size.

If max size is set to 0, size is unlimited. By default max size is set to 0

Source

pub fn inflight(self, val: usize) -> Self

Number of in-flight concurrent messages.

in-flight is set to 15 messages

Source

pub fn subscribe<F, Srv>(self, subscribe: F) -> Self
where F: IntoServiceFactory<Srv>, Srv: ServiceFactory<Config = St, Request = Subscribe<St>, Response = SubscribeResult> + 'static, C::Error: From<Srv::Error> + From<Srv::InitError>,

Service to execute for subscribe packet

Source

pub fn unsubscribe<F, Srv>(self, unsubscribe: F) -> Self
where F: IntoServiceFactory<Srv>, Srv: ServiceFactory<Config = St, Request = Unsubscribe<St>, Response = ()> + 'static, C::Error: From<Srv::Error> + From<Srv::InitError>,

Service to execute for unsubscribe packet

Source

pub fn disconnect<F, Out>( self, disconnect: F, ) -> MqttServer<Io, St, C, impl Fn(St, bool)>
where F: Fn(St, bool) -> Out, Out: Future + 'static,

Callback to execute on disconnect

Second parameter indicates error occured during disconnect.

Source

pub fn finish<F, P>( self, publish: F, ) -> impl ServiceFactory<Config = (), Request = Io, Response = (), Error = MqttError<C::Error>>
where Io: AsyncRead + AsyncWrite + 'static, F: IntoServiceFactory<P>, P: ServiceFactory<Config = St, Request = Publish<St>, Response = ()> + 'static, C::Error: From<P::Error> + From<P::InitError>,

Set service to execute for publish packet and create service factory

Auto Trait Implementations§

§

impl<Io, St, C, U> Freeze for MqttServer<Io, St, C, U>
where C: Freeze, U: Freeze,

§

impl<Io, St, C, U> !RefUnwindSafe for MqttServer<Io, St, C, U>

§

impl<Io, St, C, U> !Send for MqttServer<Io, St, C, U>

§

impl<Io, St, C, U> !Sync for MqttServer<Io, St, C, U>

§

impl<Io, St, C, U> Unpin for MqttServer<Io, St, C, U>
where C: Unpin, U: Unpin, Io: Unpin, St: Unpin,

§

impl<Io, St, C, U> !UnwindSafe for MqttServer<Io, St, C, U>

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.