Skip to main content

ErrorCode

Enum ErrorCode 

Source
pub enum ErrorCode {
Show 36 variants ProtocolVersionUnsupported, ProtocolFrameInvalid, ProtocolCodecUnsupported, ProtocolPayloadTooLarge, ProtocolRequiredFieldMissing, ProtocolSchemaMismatch, ProtocolOrderViolation, AuthRequired, AuthInvalid, AuthExpired, AuthRevoked, PermissionDenied, TopicForbidden, SessionNotFound, SessionExpired, SessionConflict, ResumeRejected, ReplayOffsetExpired, SnapshotRequired, TopicNotFound, TopicClosed, TopicOverloaded, TopicSubscriberLimit, TopicPublisherLimit, TopicRateLimited, MessageDuplicate, MessageExpired, MessageRejected, MessageTooLarge, MessageAckTimeout, MessageDeliveryFailed, SystemOverloaded, SystemMaintenance, SystemShardMoved, SystemRegionUnavailable, SystemInternal,
}
Expand description

Stable, machine-readable error code returned in a Frame::error().

Each variant represents a single, well-defined failure condition in the Rift/1 protocol. Variants are grouped by category (protocol, auth, session, topic, message, system) for clarity.

§Wire Representation

On the wire, an error code is transmitted as its RIFT_* string identifier (obtained via as_str). This design allows older peers to log or display unknown codes gracefully.

§Retryability

Call is_retryable to determine whether the error is transient and can be retried with back-off.

Variants§

§

ProtocolVersionUnsupported

The requested protocol version is not supported by the server.

This typically means the client is too old (or too new) for the server’s supported version range. The client should upgrade or negotiate a compatible version.

§

ProtocolFrameInvalid

The received frame is structurally invalid (malformed header, missing required fields, etc.).

This indicates a bug in the sender’s frame encoder.

§

ProtocolCodecUnsupported

The requested content codec is not supported.

The client should fall back to a codec listed in the server’s Welcome capabilities or disconnect.

§

ProtocolPayloadTooLarge

The frame payload exceeds the server’s configured maximum size.

The client should split the payload across multiple frames or reduce the message size.

§

ProtocolRequiredFieldMissing

A required field is missing from the frame.

This is a protocol-level validation error indicating that the sender omitted a field that the receiver requires.

§

ProtocolSchemaMismatch

The frame contents do not match the expected schema.

This may occur when the client and server disagree on the structure of a particular frame type.

§

ProtocolOrderViolation

Frames were received out of the required order (e.g. a Publish before a Subscribe).

The client must ensure it follows the frame sequencing rules defined in the Rift/1 specification.

§

AuthRequired

Authentication is required but no credentials were provided.

The client must include credentials in its Hello frame or subsequent authentication exchange.

§

AuthInvalid

The supplied credentials are syntactically or semantically invalid.

This can happen when a token is malformed, a signature is incorrect, or the credential type is unrecognized.

§

AuthExpired

The supplied credentials have expired.

The client must obtain fresh credentials (e.g. refresh the bearer token) before retrying.

§

AuthRevoked

The supplied credentials have been explicitly revoked.

Unlike expiration, revocation is an active administrative action. The client should prompt the user to re-authenticate.

§

PermissionDenied

The authenticated principal does not have permission for the requested operation.

The client should not retry unless the user’s permissions change.

§

TopicForbidden

The authenticated principal is not allowed to access the requested topic.

This is a topic-scoped variant of PermissionDenied.

§

SessionNotFound

The referenced session could not be found.

This typically means the session ID provided by the client is unknown to the server, possibly because the session has been garbage-collected.

§

SessionExpired

The referenced session has expired and is no longer valid.

The client must establish a new session.

§

SessionConflict

Another connection is already bound to the requested session.

The server enforces single-connection-per-session semantics. The client should either wait or request a new session.

§

ResumeRejected

The server rejected the client’s resume request.

This may happen when the server cannot honour the resume for internal reasons (e.g. state migration in progress).

§

ReplayOffsetExpired

The replay offset requested by the client has fallen outside the server’s retention window.

The client must perform a full snapshot catch-up instead of incremental replay.

§

SnapshotRequired

A full snapshot is required before the session can be resumed.

The server cannot provide incremental replay and needs the client to fetch a complete state snapshot first.

§

TopicNotFound

The requested topic does not exist.

The client may need to create the topic first (if the server supports auto-creation) or use a different topic name.

§

TopicClosed

The requested topic has been closed for publishing.

No new messages can be published to this topic. Subscribers may still receive buffered messages.

§

TopicOverloaded

The topic is temporarily overloaded and cannot accept more work.

This is a transient condition; the client should retry with exponential back-off.

§

TopicSubscriberLimit

The topic has reached its maximum number of subscribers.

The client should retry later or use a different topic.

§

TopicPublisherLimit

The topic has reached its maximum number of publishers.

The client should retry later or use a different topic.

§

TopicRateLimited

The topic’s per-publisher rate limit has been exceeded.

The client must reduce its publish rate or wait before retrying.

§

MessageDuplicate

The message is a duplicate of one already processed.

The server uses message IDs to detect and reject duplicates. The client should not retry with the same message ID.

§

MessageExpired

The message has expired (TTL reached zero).

The message was queued but could not be delivered before its time-to-live window elapsed.

§

MessageRejected

The message was rejected by the topic’s validation rules.

This may be due to schema validation, size constraints, or other topic-level admission policies.

§

MessageTooLarge

The message payload exceeds the maximum allowed size.

The client should compress or split the payload.

§

MessageAckTimeout

The server did not receive an acknowledgement for the message within the configured timeout window.

This applies to messages that require at-least-once delivery confirmation.

§

MessageDeliveryFailed

The message could not be delivered to its destination.

This is a transient condition; the client should retry.

§

SystemOverloaded

The server is temporarily overloaded (CPU, memory, connections).

The client should back off and retry with exponential delay.

§

SystemMaintenance

The server is undergoing scheduled maintenance.

The client should disconnect and reconnect after the maintenance window.

§

SystemShardMoved

The relevant shard has moved to a different node.

The client should reconnect; the new node will be discovered through the routing layer.

§

SystemRegionUnavailable

The target region is currently unavailable.

The client should fail over to a different region if available.

§

SystemInternal

An unexpected internal error occurred.

This indicates a server-side bug. The client may retry but should report the error if it persists.

Implementations§

Source§

impl ErrorCode

Source

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

Returns the stable wire-format string identifier for this error code.

All identifiers are prefixed with RIFT_ and use SCREAMING_SNAKE_CASE. This string is what is transmitted inside an Error frame so that older peers can log or display unknown codes without panicking.

use rifts::protocol::error_code::ErrorCode;

assert_eq!(ErrorCode::AuthInvalid.as_str(), "RIFT_AUTH_INVALID");
assert_eq!(ErrorCode::SystemInternal.as_str(), "RIFT_SYSTEM_INTERNAL");
Source

pub fn is_retryable(self) -> bool

Returns true if this error condition is generally safe to retry with exponential back-off.

Transient conditions – such as system overload, shard migration, topic rate limiting, or message delivery failure – are considered retryable. Permanent failures – such as invalid credentials or protocol violations – are not retryable because retrying would not change the outcome.

The following error codes are retryable:

use rifts::protocol::error_code::ErrorCode;

assert!(ErrorCode::SystemOverloaded.is_retryable());
assert!(!ErrorCode::AuthInvalid.is_retryable());

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

Source§

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

Formats the error code by delegating to as_str, producing the stable RIFT_* wire identifier.

This is equivalent to calling as_str() and is suitable for inclusion in log messages and user-facing error reports.

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

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> 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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more