Skip to main content

ErrorCode

Enum ErrorCode 

Source
pub enum ErrorCode {
Show 19 variants UnsupportedProtocolVersion, MalformedFrame, UnknownCommand, FrameTooLarge, PayloadTooLarge, StaleRequest, DuplicateRequest, TooManyPending, NotAuthorized, DeviceOffline, UnknownService, ServiceActionFailed, UnknownRun, UnknownApproval, ApprovalExpired, Timeout, RateLimited, CapabilityUnavailable, InternalError,
}
Expand description

Why a frame was refused, or why the operation behind it did not happen.

Non-exhaustive is deliberate on the reading side only: a peer that meets a code it does not know treats it as ErrorCode::InternalError rather than failing to parse, so adding a code in a later minor revision cannot break an older client. The serde representation below is what makes that work.

Variants§

§

UnsupportedProtocolVersion

The frame named a major version this peer cannot speak at all.

§

MalformedFrame

The bytes were not a valid envelope: bad JSON, missing field, unknown field, wrong type.

§

UnknownCommand

The envelope parsed, but type is not a name this peer accepts in this direction. A response type arriving at the daemon is this, not ErrorCode::MalformedFrame.

§

FrameTooLarge

The frame was larger than super::limits::MAX_FRAME_BYTES. Answered only when the frame was small enough to identify; past that the socket simply closes.

§

PayloadTooLarge

A field inside a well-formed frame exceeded its own limit — a prompt over 16 KiB, say.

§

StaleRequest

sentAt is outside the window in super::limits. The sender has almost certainly stopped waiting.

§

DuplicateRequest

This request id was already seen inside the dedup window and the operation is not one that may run twice.

§

TooManyPending

The device already has super::limits::MAX_PENDING_COMMANDS requests in flight.

§

NotAuthorized

The credential is revoked, belongs to another device, or the caller does not own this device.

§

DeviceOffline

No daemon socket is currently attached to this device. Never queued — presence fails closed.

§

UnknownService

No service by that exact name is registered. The remote surface never takes a pattern, so this is always an exact-name miss.

§

ServiceActionFailed

The daemon tried the action and it failed. The only code here that carries a message written by the local runtime rather than the protocol.

§

UnknownRun

No agent run by that id, or one that has already finished.

§

UnknownApproval

No pending approval by that id on that run.

§

ApprovalExpired

The approval was answered by its own expiry before the human answered it. Always a deny, never a silent drop.

§

Timeout

The operation was still running when its deadline passed. Not retryable: the daemon may yet finish it.

§

RateLimited

A per-IP, per-user or per-device rate limit refused the frame.

§

CapabilityUnavailable

The peer speaks this protocol version but not this capability — an older daemon meeting a feature that shipped after it. Rendered to a user as “your machine needs updating”, never as a failure.

§

InternalError

Anything else, and anything a peer does not recognise.

Implementations§

Source§

impl ErrorCode

Source

pub const ALL: &'static [Self]

Every code, in wire order. The exhaustiveness tests and the generated documentation both read this, so a new variant that is not listed here fails the build’s own tests rather than shipping undocumented.

Source

pub const fn retryable(self) -> bool

Whether the same request id may be sent again by an automatic retry.

True only where the operation provably did not start. Everything ambiguous — a timeout above all — is false, and is a decision for a human looking at the machine’s real state.

Source

pub const fn fatal_to_session(self) -> bool

Whether meeting this code should close the device socket.

A daemon that cannot be trusted to frame correctly is not a daemon whose next frame should be believed.

Source

pub const fn as_str(self) -> &'static str

The wire spelling. Kept as a method as well as a serde attribute so the fixture tests can assert the exact string without a round trip.

Trait Implementations§

Source§

impl Clone for ErrorCode

Source§

fn clone(&self) -> ErrorCode

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 Copy for ErrorCode

Source§

impl Debug for ErrorCode

Source§

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

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

impl<'de> Deserialize<'de> for ErrorCode

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for ErrorCode

Source§

impl Hash for ErrorCode

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for ErrorCode

Source§

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

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

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

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

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for ErrorCode

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl PartialOrd for ErrorCode

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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 Serialize for ErrorCode

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ErrorCode

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<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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 = !

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.