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.
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
impl ErrorCode
Sourcepub fn as_str(self) -> &'static str
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");Sourcepub fn is_retryable(self) -> bool
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:
SystemOverloadedSystemShardMovedSystemRegionUnavailableTopicOverloadedTopicRateLimitedReplayOffsetExpiredMessageDeliveryFailedMessageAckTimeout
use rifts::protocol::error_code::ErrorCode;
assert!(ErrorCode::SystemOverloaded.is_retryable());
assert!(!ErrorCode::AuthInvalid.is_retryable());