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
impl Clone for ResponseCode
Source§fn clone(&self) -> ResponseCode
fn clone(&self) -> ResponseCode
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ResponseCode
impl Debug for ResponseCode
Source§impl From<ResponseCode> for Error
impl From<ResponseCode> for Error
Source§fn from(code: ResponseCode) -> Error
fn from(code: ResponseCode) -> Error
Source§impl FromPrimitive for ResponseCode
impl FromPrimitive for ResponseCode
Source§fn from_i64(n: i64) -> Option<Self>
fn from_i64(n: i64) -> Option<Self>
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>
fn from_u64(n: u64) -> Option<Self>
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>
fn from_isize(n: isize) -> Option<Self>
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>
fn from_i8(n: i8) -> Option<Self>
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>
fn from_i16(n: i16) -> Option<Self>
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>
fn from_i32(n: i32) -> Option<Self>
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>
fn from_i128(n: i128) -> Option<Self>
i128
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read moreSource§fn from_usize(n: usize) -> Option<Self>
fn from_usize(n: usize) -> Option<Self>
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>
fn from_u8(n: u8) -> Option<Self>
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>
fn from_u16(n: u16) -> Option<Self>
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>
fn from_u32(n: u32) -> Option<Self>
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>
fn from_u128(n: u128) -> Option<Self>
u128
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read more