pub struct MqttServer<LoginH, SubH> { /* private fields */ }Expand description
A complete MQTT Server
This server should be seen as a toolkit to integrate with your application.
To use it, you first need to get a new instance of it, check out any of the serve_* methods
that create a new instance.
Then, you need to start listening for new connections in a long lived future.
Check out the server example for a working version.
Implementations§
Source§impl MqttServer<AllowAllLogins, AllowAllSubscriptions>
impl MqttServer<AllowAllLogins, AllowAllSubscriptions>
Sourcepub async fn serve_v3_unsecured_tcp<Addr: ToSocketAddrs>(
addr: Addr,
) -> Result<Self, MqttError>
pub async fn serve_v3_unsecured_tcp<Addr: ToSocketAddrs>( addr: Addr, ) -> Result<Self, MqttError>
Create a new MQTT server listening on the given SocketAddr
Source§impl<LH: LoginHandler, SH: SubscriptionHandler> MqttServer<LH, SH>
impl<LH: LoginHandler, SH: SubscriptionHandler> MqttServer<LH, SH>
Sourcepub fn with_login_handler<NLH: LoginHandler>(
self,
new_login_handler: NLH,
) -> MqttServer<NLH, SH>
pub fn with_login_handler<NLH: LoginHandler>( self, new_login_handler: NLH, ) -> MqttServer<NLH, SH>
Switch the login handler with a new one
§Note
You should only call this after instantiating the server, and before listening
Sourcepub fn with_subscription_handler<NSH: SubscriptionHandler>(
self,
new_subscription_handler: NSH,
) -> MqttServer<LH, NSH>
pub fn with_subscription_handler<NSH: SubscriptionHandler>( self, new_subscription_handler: NSH, ) -> MqttServer<LH, NSH>
Resets the subscription handler to a new one
§Note
You should only call this after instantiating the server, and before listening
Sourcepub async fn accept_new_clients(&self) -> Result<(), MqttError>
pub async fn accept_new_clients(&self) -> Result<(), MqttError>
Start accepting new clients connecting to the server
Trait Implementations§
Auto Trait Implementations§
impl<LoginH, SubH> Freeze for MqttServer<LoginH, SubH>
impl<LoginH, SubH> !RefUnwindSafe for MqttServer<LoginH, SubH>
impl<LoginH, SubH> Send for MqttServer<LoginH, SubH>
impl<LoginH, SubH> Sync for MqttServer<LoginH, SubH>
impl<LoginH, SubH> Unpin for MqttServer<LoginH, SubH>
impl<LoginH, SubH> UnsafeUnpin for MqttServer<LoginH, SubH>
impl<LoginH, SubH> !UnwindSafe for MqttServer<LoginH, SubH>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<I, T> ExtractContext<I, ()> for T
impl<I, T> ExtractContext<I, ()> for T
Source§fn extract_context(self, _original_input: I)
fn extract_context(self, _original_input: I)
Given the context attached to a nom error, and given the original
input to the nom parser, extract more the useful context information. Read more
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<I> RecreateContext<I> for I
impl<I> RecreateContext<I> for I
Source§fn recreate_context(_original_input: I, tail: I) -> I
fn recreate_context(_original_input: I, tail: I) -> I
Given the original input, as well as the context reported by nom,
recreate a context in the original string where the error occurred. Read more