Skip to main content

Refusal

Struct Refusal 

Source
pub struct Refusal<'a> {
    pub reason: RefusalReason,
    pub capability: Capability,
    pub detail: &'a str,
}
Expand description

One side declining to go on, and saying why.

The reason a refusal is a record rather than a dropped connection is that “this did not work” is not an actionable message. Somebody has to be able to read the failure and know which capability to go and implement.

Fields§

§reason: RefusalReason

The category of problem.

§capability: Capability

Which capability was missing, when reason is RefusalReason::MISSING_CAPABILITY.

§detail: &'a str

Text for a human. Not parsed by anything.

Implementations§

Source§

impl<'a> Refusal<'a>

Source

pub const VERSION: u16 = 1

The layout version of this record.

Source

pub const fn new(reason: RefusalReason, detail: &'a str) -> Self

A refusal with no particular capability attached.

Source

pub fn encode(&self, w: &mut Writer<'_>) -> Result<()>

Writes the record.

§Errors

Returns Error::BufferFull if the buffer runs out.

Source

pub fn decode(version: u16, p: &mut Reader<'a>) -> Result<Self>

Reads the record from its payload.

§Errors

Returns Error::UnsupportedVersion if the layout version is not one this build knows, Error::Truncated if the payload ends early, or Error::NotUtf8 if the detail is not text.

Trait Implementations§

Source§

impl<'a> Clone for Refusal<'a>

Source§

fn clone(&self) -> Refusal<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for Refusal<'a>

Source§

impl<'a> Debug for Refusal<'a>

Source§

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

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

impl<'a> Eq for Refusal<'a>

Source§

impl<'a> PartialEq for Refusal<'a>

Source§

fn eq(&self, other: &Refusal<'a>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> StructuralPartialEq for Refusal<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Refusal<'a>

§

impl<'a> RefUnwindSafe for Refusal<'a>

§

impl<'a> Send for Refusal<'a>

§

impl<'a> Sync for Refusal<'a>

§

impl<'a> Unpin for Refusal<'a>

§

impl<'a> UnsafeUnpin for Refusal<'a>

§

impl<'a> UnwindSafe for Refusal<'a>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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>,

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.