Skip to main content

BridgeError

Enum BridgeError 

Source
pub enum BridgeError<SE, TE> {
    TcpClosed,
    RtuClosed,
    TcpIo(TE),
    RtuIo(SE),
    RtuCrcMismatch,
    BufferOverflow,
    Timeout,
}
Expand description

Hard error returned by Connection::next.

On any BridgeError the caller should exit the connection loop, close the TCP stream, and call Bridge::accept for the next client:

loop {
    match conn.next().await {
        Ok(event) => { /* handle */ }
        Err(BridgeError::TcpClosed) => break,  // normal disconnect
        Err(e) => { defmt::error!("{}", e); break; }  // hard error
    }
}
conn.into_stream().close();

SE is the serial-port error type and TE is the TCP-stream error type. Both come from the embedded_io_async::ErrorType (or [embedded_io::ErrorType]) implementations of the serial and TCP types passed to BridgeBuilder.

Variants§

§

TcpClosed

TCP client closed the connection cleanly (EOF / zero-byte read).

This is the normal exit condition and is not an error in itself. Break the connection loop and accept the next client.

§

RtuClosed

RTU master closed the serial connection cleanly (EOF / zero-byte read).

Normal exit condition in client mode — equivalent to TcpClosed in bridge mode.

§

TcpIo(TE)

TCP I/O error from the underlying stream.

§

RtuIo(SE)

Serial (RTU) I/O error from the underlying serial port.

§

RtuCrcMismatch

RTU device response failed CRC-16 verification.

This usually indicates a wiring problem, an incorrect baud rate, or electrical noise on the RS-485 bus.

§

BufferOverflow

A Modbus frame was larger than the internal frame buffer can hold.

The internal buffers support the full Modbus specification maximum (255-byte RTU / 261-byte TCP). This error indicates a malformed or non-Modbus frame.

§

Timeout

An RTU or TCP I/O operation did not complete within the configured timeout.

Trait Implementations§

Source§

impl<SE: Debug, TE: Debug> Debug for BridgeError<SE, TE>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<SE: Debug, TE: Debug> Display for BridgeError<SE, TE>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<SE, TE> Freeze for BridgeError<SE, TE>
where TE: Freeze, SE: Freeze,

§

impl<SE, TE> RefUnwindSafe for BridgeError<SE, TE>

§

impl<SE, TE> Send for BridgeError<SE, TE>
where TE: Send, SE: Send,

§

impl<SE, TE> Sync for BridgeError<SE, TE>
where TE: Sync, SE: Sync,

§

impl<SE, TE> Unpin for BridgeError<SE, TE>
where TE: Unpin, SE: Unpin,

§

impl<SE, TE> UnsafeUnpin for BridgeError<SE, TE>
where TE: UnsafeUnpin, SE: UnsafeUnpin,

§

impl<SE, TE> UnwindSafe for BridgeError<SE, TE>
where TE: UnwindSafe, SE: UnwindSafe,

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.