pub struct Error { /* private fields */ }
Expand description

A build-time-flexible renderable error type

This is used wherever this crate produces errors, and also recommended for outside handlers – the idea being that the more code parts share a type, the more compact code can be emitted.

Depending on what gets configured, it may just be a single u8 error code, or it may contain more details such as the number of the option that could not be processed, or any other Standard Problem Details (RFC9290).

Implementations§

source§

impl Error

source

pub fn bad_option(unprocessed_option: u16) -> Self

Create an error response for an unprocessed option

The response is rendered with a single unprocessed-coap-option problem detail if that feature is enabled.

If the unprocessed option has a special error code (e.g. Accept => 4.06 Not Acceptable or Content Format => 4.15 Unsupported Content-Format), that code is emitted instead of the default 4.02 Bad Option, and the unprocessed-coap-option problem details is not emitted.

Note that the CoAP option number is given as a u16, as is common around the CoAP crates (even though 0 is a reseved value). It is an error to pass in the value 0; the implementation may treat this as a reason for a panic, or silently ignore the error and not render the problem detail.

source

pub fn bad_request_with_rbep(byte: usize) -> Self

Create a 4.00 Bad Request error with a Request Body Error Position indicating at which position in the request’s body the error occurred

If the crate is compiled without the error_request_body_error_position feature, the position information will be ignored. The value may also be ignored if it exceeds an internal limit of how large values can be expressed.

source

pub fn bad_request() -> Self

Create an otherwise empty 4.00 Bad Request error

source

pub fn not_found() -> Self

Create an otherwise empty 4.04 Not Found error

source

pub fn method_not_allowed() -> Self

Create an otherwise empty 4.05 Method Not Allowed error

source

pub fn internal_server_error() -> Self

Create an otherwise empty 5.00 Internal Server Error error

source

pub fn service_unavailable() -> Self

Create an otherwise empty 5.03 Service Unavailable error

source

pub fn with_max_age(self, max_age: u32) -> Self

Available on crate feature error_max_age only.

Set a Max-Age

Unlike the constructors that set error details, this modifier is only available when the data is actually stored, because not emitting it is not just elision of possibly helful details, but may change the networks’ behavior (for example, because a long Max-Age is not sent and the client keeps retrying every minute).

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 RenderableOnMinimal for Error

§

type Error<IE: RenderableOnMinimal + Debug> = IE

Error to return when even the error rendering is unsuccessful (a “double error”). Read more
source§

fn render<M: MinimalWritableMessage>( self, message: &mut M ) -> Result<(), Self::Error<M::UnionError>>

Express the error in a CoAP response message Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnwindSafe 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.