pub enum Error {
Show 14 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),
}Expand description
Top-level error type for the BACnet library.
Variants§
Protocol
BACnet protocol error response (Clause 20.1.7).
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
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).
Abort
BACnet abort PDU (Clause 20.1.6).
RoutedPathTooLong
A router reported that the active message was too long for a routed path.
RoutedPathCapacityExceeded
The client cannot safely allocate state for another routed path.
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
Encoding(String)
Error encoding a PDU.
Decoding
Error decoding received data.
Fields
kind: DecodingKindWhich kind of fault the decoder found.
Transport(Error)
Transport-level I/O error.
Timeout(Duration)
Request timed out.
Segmentation(String)
Segmentation assembly error.
BufferTooShort
Buffer too short for the expected data.
OutOfRange(String)
Value out of valid range.
Implementations§
Source§impl Error
impl Error
Sourcepub fn protocol(class: u32, code: u32, detail: Option<ErrorDetail>) -> Self
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.
Sourcepub fn decoding(offset: usize, message: impl Into<String>) -> Self
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.
Sourcepub fn decoding_kind(
kind: DecodingKind,
offset: usize,
message: impl Into<String>,
) -> Self
pub fn decoding_kind( kind: DecodingKind, offset: usize, message: impl Into<String>, ) -> Self
Create a decoding error of kind at the given byte offset.
Sourcepub fn invalid_tag(offset: usize, message: impl Into<String>) -> Self
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.
Sourcepub fn missing(offset: usize, message: impl Into<String>) -> Self
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.
Sourcepub fn trailing(offset: usize, message: impl Into<String>) -> Self
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.
Sourcepub fn out_of_range(offset: usize, message: impl Into<String>) -> Self
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.
Sourcepub fn overflow(offset: usize, message: impl Into<String>) -> Self
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.
Sourcepub fn reject_reason(&self) -> Option<RejectReason>
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.
Sourcepub fn into_request_reject(self) -> Self
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.
Sourcepub fn buffer_too_short(need: usize, have: usize) -> Self
pub fn buffer_too_short(need: usize, have: usize) -> Self
Create a buffer-too-short error.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()