Skip to main content

DeviceError

Enum DeviceError 

Source
#[non_exhaustive]
pub enum DeviceError { SduTooLarge { got: usize, max: u16, }, UnknownLane(LaneKey), TxUnavailable, Closed, Device(String), }
Expand description

Why a medium refused or failed an SDU.

#[non_exhaustive]: both consumers on the data path already match with a catch-all (sched.rs’s retry arm, lanes.rs’s receive loop), so this costs nothing today and leaves room for the variants a real device will need. The alternative is discovering later that adding one is a breaking change to a crate whose whole job is to be implemented from outside.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

SduTooLarge

The SDU is larger than the medium can carry.

Invariant I4: the driver never splits a batch to make it fit. An SDU that does not fit is a configuration error — Zenoh’s batch_size was set above what this medium can carry — and it is reported, loudly, as one.

Fields

§got: usize
§max: u16
§

UnknownLane(LaneKey)

No such lane is configured on this medium.

§

TxUnavailable

The medium is up but cannot transmit right now, and says so rather than waiting.

For hardware whose API refuses instead of blocking — a half-duplex medium mid-reception, on a device that reports rather than queues.

A contact window is still not an instance of this. A satellite terminal out of coverage blocks, because that is what a store-and-forward service does. See docs/measurements/contact-windows.md.

What returning it costs, exactly: on a reliable lane the scheduler holds the batch and offers it again with a backoff, for as long as the medium keeps refusing (#40) — so this trades a stall for a delay, never for lost data, and the stall reaches Zenoh as ordinary backpressure. On a best-effort lane the batch is dropped and counted, which is what best-effort means. Either way the refusal appears on DriverMetrics::tx_failed.

Earlier versions of this note warned that the scheduler dropped the batch on both lane classes. It did, silently, and that was #40.

§

Closed

The medium is gone: closed, unplugged, or failed.

§

Device(String)

Anything hardware-specific, in the backend’s own words.

Handled exactly as DeviceError::TxUnavailable: held and retried on a reliable lane, dropped and counted on a best-effort one. Return it for a failure the medium expects to survive — +CME ERROR, an SPI timeout, an MO status of “no network”. A device that is gone should say DeviceError::Closed instead, which stops the driver rather than retrying into it.

The string reaches the management plane verbatim. sched::transmit raises a DeviceEvent carrying it, the driver’s event stream carries that, and it is published as events/modem/device_fault/<ulid> with the text in detail (#51). Write it for an operator, not for a log grep: it is the only place a device speaks in its own words.

Trait Implementations§

Source§

impl Debug for DeviceError

Source§

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

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

impl Display for DeviceError

Source§

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

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

impl Error for DeviceError

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more

Auto Trait Implementations§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.