Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error {
Show 16 variants Protocol { class: u32, code: u32, }, Structured { class: u32, code: u32, detail: Box<ErrorDetail>, }, Reject { reason: u8, }, Abort { reason: u8, }, RoutedPathTooLong { dnet: u16, }, RoutedPathCapacityExceeded { capacity: usize, }, UnsupportedTransport { required: DataLink, actual: DataLink, }, Encoding(String), Decoding { offset: usize, kind: DecodingKind, message: String, }, Transport(Error), Timeout(Duration), Segmentation(String), BufferTooShort { need: usize, have: usize, }, OutOfRange(String), ReadRangeViolation(ReadRangeViolation), LogNotAdvancing { requested: u64, returned: Option<u64>, },
}
Expand description

Top-level error type for the BACnet library.

It is #[non_exhaustive], so a match on it outside this crate needs a wildcard arm. Error::Transport exists only with the std feature, and any crate in a build can turn that on, so without the attribute a match written against the alloc build would stop compiling (#1604).

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.
§

Protocol

BACnet protocol error response (Clause 20.1.7).

Fields

§class: u32

Error class value.

§code: u32

Error code value.

§

Structured

BACnet error response whose Clause 21 production carries more than the class and code: ChangeList-Error, CreateObject-Error, WritePropertyMultiple-Error, SubscribeCOVPropertyMultiple-Error, ConfirmedPrivateTransfer-Error or VTClose-Error. detail holds the extra fields; a body whose optional fields are all absent is reported as Error::Protocol.

Fields

§class: u32

Error class value.

§code: u32

Error code value.

§detail: Box<ErrorDetail>

The production’s fields after the class and code. Boxed so the rare structured error does not widen every Result<_, Error>.

§

Reject

BACnet reject PDU (Clause 20.1.5).

Fields

§reason: u8

Reject reason value.

§

Abort

BACnet abort PDU (Clause 20.1.6).

Fields

§reason: u8

Abort reason value.

§

RoutedPathTooLong

A router reported that the active message was too long for a routed path.

Fields

§dnet: u16

Destination network rejected by the router.

§

RoutedPathCapacityExceeded

The client cannot safely allocate state for another routed path.

Fields

§capacity: usize

Maximum number of immediate-router/DNET path entries retained.

§

UnsupportedTransport

The endpoint’s transport cannot carry the requested operation, such as a BBMD management request through a data link other than BACnet/IP. Nothing was sent.

Fields

§required: DataLink

Data link the operation needs.

§actual: DataLink

Data link the endpoint’s transport carries.

§

Encoding(String)

Error encoding a PDU.

§

Decoding

Error decoding received data.

Fields

§offset: usize

Byte offset where the error occurred.

§kind: DecodingKind

Which kind of fault the decoder found.

§message: String

Description of what went wrong.

§

Transport(Error)

Transport-level I/O error. Only with the std feature, which has std::io.

§

Timeout(Duration)

Request timed out.

§

Segmentation(String)

Segmentation assembly error.

§

BufferTooShort

Buffer too short for the expected data.

Fields

§need: usize

Minimum bytes needed.

§have: usize

Bytes actually available.

§

OutOfRange(String)

Value out of valid range.

§

ReadRangeViolation(ReadRangeViolation)

A well-formed ReadRange acknowledgement that breaks a rule the client checks against the request it answers, so the client refused it. The acknowledgement decoded; a malformed one is Error::Decoding instead. Read again leniently to keep its items.

§

LogNotAdvancing

A paged log read asked for the records from one sequence number and the device answered with a page starting before it, so reading on would repeat records instead of advancing; or answered with none although its record counts say it holds that record. Some devices clamp a reference past their sequence wrap back to the oldest record, or number the record after the wrap 0; read such a log by position instead.

Fields

§requested: u64

The sequence number the read asked for.

§returned: Option<u64>

What the device numbered the first record it sent; None when it returned no records.

Implementations§

Source§

impl Error

Source

pub fn protocol(class: u32, code: u32, detail: Option<ErrorDetail>) -> Self

The error an Error PDU reports: Error::Structured when its body carried a detail, Error::Protocol otherwise.

Source

pub fn decoding(offset: usize, message: impl Into<String>) -> Self

Create a DecodingKind::InvalidEncoding decoding error at the given byte offset: contents whose encoding isn’t valid for their datatype.

Source

pub fn decoding_kind( kind: DecodingKind, offset: usize, message: impl Into<String>, ) -> Self

Create a decoding error of kind at the given byte offset.

Source

pub fn invalid_tag(offset: usize, message: impl Into<String>) -> Self

Create a DecodingKind::InvalidTag decoding error: a tag at offset that doesn’t fit there.

Source

pub fn missing(offset: usize, message: impl Into<String>) -> Self

Create a DecodingKind::Missing decoding error: a required member due at offset isn’t there.

Source

pub fn trailing(offset: usize, message: impl Into<String>) -> Self

Create a DecodingKind::Trailing decoding error: octets from offset on that the value leaves unread.

Source

pub fn out_of_range(offset: usize, message: impl Into<String>) -> Self

Create a DecodingKind::OutOfRange decoding error: a value at offset too large for its field, or outside its range.

Source

pub fn overflow(offset: usize, message: impl Into<String>) -> Self

Create a DecodingKind::Overflow decoding error: more items, or a longer tag, than the decoder takes.

Source

pub fn reject_reason(&self) -> Option<RejectReason>

The Reject reason a responder answers a confirmed request with when this error refused it while decoding its parameters (Clauses 18.9 and 20.1.8): the reason itself for Error::Reject, the kind’s reason for Error::Decoding (the table on DecodingKind::reject_reason), and MISSING_REQUIRED_PARAMETER for Error::BufferTooShort, a member cut short because the data ran out before it was complete. None for any other error, which no decoder of the request’s parameters reports.

Source

pub fn into_request_reject(self) -> Self

This error, met decoding a confirmed request’s own parameters, as the Error::Reject a responder answers with: the reject_reason when it is a syntax fault, the error unchanged otherwise.

A responder converts only the request’s decode with this. A decoding error met later, once the service has started to run, is no reason to reject the request (Clause 20.1.8), so it stays as it is.

Source

pub fn buffer_too_short(need: usize, have: usize) -> Self

Create a buffer-too-short error.

Trait Implementations§

Source§

impl Debug for Error

Source§

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

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

impl Display for Error

Source§

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

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

impl Error for Error

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
Source§

impl From<Error> for Error

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Error

§

impl !UnwindSafe for Error

§

impl Freeze for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

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.