Enum ResponseCode

Source
pub enum ResponseCode {
Show 24 variants Success = 0, Continuation = 1, NeedsAuthentication = 65_536, Forbidden = 65_537, Closing = 65_538, Errno = 65_539, AuthenticationFailed = 65_540, Gone = 65_541, NotFound = 65_542, InternalError = 65_543, ChannelDead = 65_544, Aborted = 65_545, ContinuationNotFound = 65_546, OutOfRange = 65_547, NoSpace = 65_548, Conflict = 65_549, Unlistable = 65_550, NotEnabled = 131_072, NotSupported = 131_073, ParametersNotSupported = 131_074, Invalid = 131_075, TooLarge = 131_076, TooManyMessages = 131_077, InvalidParameters = 131_078,
}
Expand description

§Overview

The protocol is relatively simple. Each request consists of a 32-bit size of the resulting message, a 32-bit request ID, a 32-bit message type, and an optional per-message CBOR blob representing message data. For performance and security reasons, the message size is limited to 2^24 in size. The size includes all fields other than the size.

Each response consists of a 32-bit size of the message, the 32-bit request ID, a 32-bit response code, and an optional per-response code CBOR blob.

The bottom 31 bits of the request ID may be any value; the response will use the same ID. No check is made for duplicates, so the requestor should prefer not repeating IDs that are in flight. The top bit is clear if the request is client-to-server request and it is set if the request is a server-to-client request. This helps eliminate confusion as to whether a message is a request or a response.

All data is serialized in a little-endian format.

§Extension Messages

Extension values (message types and response codes) are assigned with values 0xff000000 and larger. These can be dynamically allocated using the CreateExtensionRange message, and once allocated, will allow the extension to use the given codes both as message types and response codes.

Note that an implementation is not obligated to allocate or use extension codes. For example, an implementation which offers a new sort of channel may well choose to use the existing channel codes, or it may choose to use new message types with existing response codes.

Lawn currently allocates these by allocating a 12-bit range internally, so the first code of the first extension is 0xff000000, the first code of the next is 0xfff001000, and so on. This provides 4096 codes per extension while allowing 4096 extensions. However, this algorithm is subject to change at any time. The response codes for the protocol.

The response codes are based around IMAP’s response codes, and the top two bytes of the response indicates the type:

  • 00: success
  • 01: no (roughly, the request was understood, but not completed)
  • 02: bad (roughly, the request was not understood)
  • ff: extension message (dynamically allocated)

Variants§

§

Success = 0

The request was successful. The response contains the requested data.

§

Continuation = 1

The request is incomplete, but is so far successful. The request should continue, referencing the ID of the last request.

§

NeedsAuthentication = 65_536

The request requires authentication.

The semantics for this message are equivalent to an HTTP 401 response.

§

Forbidden = 65_537

The message was not allowed.

The semantics for this message are equivalent to an HTTP 403 response.

§

Closing = 65_538

The server is shutting down.

§

Errno = 65_539

The message failed for a system error reason.

This is generally only useful for certain types of channels.

§

AuthenticationFailed = 65_540

§

Gone = 65_541

The other end of the channel has disappeared.

§

NotFound = 65_542

§

InternalError = 65_543

§

ChannelDead = 65_544

The channel has ceased to produce new data and this operation cannot complete.

§

Aborted = 65_545

The operation was aborted.

§

ContinuationNotFound = 65_546

There is no continuation with the specified parameters.

§

OutOfRange = 65_547

The result was out of range.

The semantics for this message are equivalent to ERANGE.

§

NoSpace = 65_548

There is no more space for the requested item.

§

Conflict = 65_549

The requested operation would conflict with something already existing.

The semantics for this message are equivalent to an HTTP 409 response.

§

Unlistable = 65_550

The contents of the object cannot be listed or specified by name.

For example, when using a Git-protocol credential helper, it is not possible to enumerate all credentials or pick a credential by ID.

§

NotEnabled = 131_072

The message type was not enabled.

§

NotSupported = 131_073

The message type or operation was not supported.

§

ParametersNotSupported = 131_074

The parameters were not supported.

§

Invalid = 131_075

The message type was received, but was not valid.

§

TooLarge = 131_076

The message was too large.

§

TooManyMessages = 131_077

There are too many pending messages.

§

InvalidParameters = 131_078

The parameters are supported, but not correct.

For example, if a selector is not valid for a channel, this message may be sent.

Trait Implementations§

Source§

impl Clone for ResponseCode

Source§

fn clone(&self) -> ResponseCode

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ResponseCode

Source§

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

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

impl From<ResponseCode> for Error

Source§

fn from(code: ResponseCode) -> Error

Converts to this type from the input type.
Source§

impl FromPrimitive for ResponseCode

Source§

fn from_i64(n: i64) -> Option<Self>

Converts an i64 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_u64(n: u64) -> Option<Self>

Converts an u64 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_isize(n: isize) -> Option<Self>

Converts an isize to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_i8(n: i8) -> Option<Self>

Converts an i8 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_i16(n: i16) -> Option<Self>

Converts an i16 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_i32(n: i32) -> Option<Self>

Converts an i32 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_i128(n: i128) -> Option<Self>

Converts an i128 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
Source§

fn from_usize(n: usize) -> Option<Self>

Converts a usize to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_u8(n: u8) -> Option<Self>

Converts an u8 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_u16(n: u16) -> Option<Self>

Converts an u16 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_u32(n: u32) -> Option<Self>

Converts an u32 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_u128(n: u128) -> Option<Self>

Converts an u128 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
Source§

fn from_f32(n: f32) -> Option<Self>

Converts a f32 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_f64(n: f64) -> Option<Self>

Converts a f64 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
Source§

impl Ord for ResponseCode

Source§

fn cmp(&self, other: &ResponseCode) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for ResponseCode

Source§

fn eq(&self, other: &ResponseCode) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for ResponseCode

Source§

fn partial_cmp(&self, other: &ResponseCode) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for ResponseCode

Source§

impl Eq for ResponseCode

Source§

impl StructuralPartialEq for ResponseCode

Auto Trait Implementations§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

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.