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§
Sourcefn connect(&self) -> impl Future<Output = Result<(), MqttError>>
fn connect(&self) -> impl Future<Output = Result<(), MqttError>>
Establishes the connection to the broker
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)
Sourcefn try_write_packet(&self, packet: &Packet<'_>) -> Result<bool, MqttError>
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.
Sourcefn write_packet(
&self,
packet: &Packet<'_>,
) -> impl Future<Output = Result<(), MqttError>>
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
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.