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

The ErrorCode contains a numeric error code value in the range of 300 to 699 plus a textual reason phrase encoded in UTF-8 RFC3629; it is also consistent in its code assignments and semantics with SIP RFC3261 and HTTP RFC7231. The reason phrase is meant for diagnostic purposes and can be anything appropriate for the error code. Recommended reason phrases for the defined error codes are included in the IANA registry for error codes. The reason phrase MUST be a UTF-8-encoded RFC3629 sequence of fewer than 128 characters (which can be as long as 509 bytes when encoding them or 763 bytes when decoding them).

Examples

 let attr = ErrorCode::new(420, "Unknown Attribute")?;
 assert_eq!(attr.class(), 4);
 assert_eq!(attr.number(), 20);
 assert_eq!(attr.error_code(), 420);
 assert_eq!(attr.reason(), "Unknown Attribute");

Implementations

Creates a new ErrorCode type.

Arguments:
  • error_code - The numeric error code.
  • reason - The reason phrase.
Return:

The ErrorCode type or a StunError if the numeric error value is not in the range of 300 to 699.

Returns the numeric error code value .

Returns the class of the error code (the hundreds digit).

Returns the binary encoding of the error code modulo 100.

Returns the reason phrase associated to this error.

Trait Implementations

Formats the value using the given formatter. Read more
Converts to this type from the input type.
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.