ConnectionState

Trait ConnectionState 

Source
pub trait ConnectionState {
    // Required methods
    fn connect(&self) -> impl Future<Output = Result<(), MqttError>>;
    fn disconnect(&self) -> impl Future<Output = Result<(), MqttError>>;
    fn get_state(&self) -> Option<ConnectionStateValue>;
    fn on_state_change(&self) -> impl Future<Output = ConnectionStateValue>;
    fn await_connected(&self) -> impl Future<Output = ()>;
    fn set_error(&self);
    fn try_write_packet(&self, packet: &Packet<'_>) -> Result<bool, MqttError>;
    fn write_packet(
        &self,
        packet: &Packet<'_>,
    ) -> impl Future<Output = Result<(), MqttError>>;
    fn run_io(
        &self,
    ) -> impl Future<Output = Result<impl Deref<Target = Packet<'_>>, MqttError>>;
    fn run_io_nonblocking(
        &self,
    ) -> impl Future<Output = Result<Option<impl Deref<Target = Packet<'_>>>, MqttError>>;
}

Required Methods§

Source

fn connect(&self) -> impl Future<Output = Result<(), MqttError>>

Establishes the connection to the broker

Source

fn disconnect(&self) -> impl Future<Output = Result<(), MqttError>>

Source

fn get_state(&self) -> Option<ConnectionStateValue>

Source

fn on_state_change(&self) -> impl Future<Output = ConnectionStateValue>

Source

fn await_connected(&self) -> impl Future<Output = ()>

Source

fn set_error(&self)

Source

fn try_write_packet(&self, packet: &Packet<'_>) -> Result<bool, MqttError>

Send a mqtt packet to the broker This method may return without sending the packet returning Ok(false). This indicates that the send sould be tried later.

Source

fn write_packet( &self, packet: &Packet<'_>, ) -> impl Future<Output = Result<(), MqttError>>

Writes a packet to the send buffer and sends data until teh packet fits

Source

fn run_io( &self, ) -> impl Future<Output = Result<impl Deref<Target = Packet<'_>>, MqttError>>

Run pending io tasks until there is a new packet

Source

fn run_io_nonblocking( &self, ) -> impl Future<Output = Result<Option<impl Deref<Target = Packet<'_>>>, MqttError>>

Run until there is a new packet or something has been sent

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'a, 'l, M: RawMutex, NETWORK, DNS, const BUFFER_SIZE: usize> ConnectionState for TcpConnectionState<'a, 'l, M, NETWORK, DNS, BUFFER_SIZE>
where NETWORK: TcpConnect, DNS: Dns,