pub enum Frame {
Show 25 variants
Connect {
flags: u8,
min_version: ProtocolVersion,
max_version: ProtocolVersion,
auth_token: Vec<u8>,
},
ConnectAck {
flags: u8,
selected_version: ProtocolVersion,
capabilities: u32,
},
ConnectError {
flags: u8,
reason_code: u16,
message: Option<String>,
},
Disconnect {
flags: u8,
},
Subscribe {
flags: u8,
stream_id: u32,
channel: String,
accepted_schemas: Vec<SchemaId>,
max_in_flight: u32,
},
SubscribeAck {
flags: u8,
stream_id: u32,
subscription_id: u64,
selected_schema: SchemaId,
},
SubscribeError {
flags: u8,
stream_id: u32,
reason_code: u16,
message: Option<String>,
},
Unsubscribe {
flags: u8,
stream_id: u32,
subscription_id: u64,
},
Publish {
flags: u8,
stream_id: u32,
channel: String,
envelope: MessageEnvelope,
idempotency_key: Option<String>,
},
PublishAck {
flags: u8,
stream_id: u32,
message_id: u64,
},
PublishError {
flags: u8,
stream_id: u32,
reason_code: u16,
message: Option<String>,
},
ConversationOpen {
flags: u8,
stream_id: u32,
conversation_id: u64,
subject: String,
},
ConversationMessage {
flags: u8,
stream_id: u32,
conversation_id: u64,
envelope: MessageEnvelope,
},
ConversationClose {
flags: u8,
stream_id: u32,
conversation_id: u64,
reason_code: Option<u16>,
message: Option<String>,
},
ConversationError {
flags: u8,
stream_id: u32,
conversation_id: u64,
reason_code: u16,
message: Option<String>,
},
Accept {
flags: u8,
stream_id: u32,
referenced_message_id: MessageId,
},
Defer {
flags: u8,
stream_id: u32,
referenced_message_id: MessageId,
reason: Option<String>,
},
Reject {
flags: u8,
stream_id: u32,
referenced_message_id: MessageId,
reason: Option<String>,
},
Ping {
flags: u8,
},
Pong {
flags: u8,
},
Push {
flags: u8,
stream_id: u32,
correlation_id: u64,
payload: Vec<u8>,
},
PushReply {
flags: u8,
stream_id: u32,
correlation_id: u64,
payload: Vec<u8>,
},
WorkerRegister {
flags: u8,
registration: WorkerRegistration,
},
WorkerRegisterAck {
flags: u8,
outcome: WorkerRegisterOutcome,
},
Unknown {
type_id: u8,
flags: u8,
stream_id: u32,
payload: Vec<u8>,
},
}Expand description
A typed protocol frame body plus the header metadata required to encode it.
Variants§
Connect
Connection request carrying a supported version range and opaque auth token.
ConnectAck
Connection success carrying the negotiated protocol version and server capabilities.
ConnectError
Connection failure carrying a numeric reason and optional message.
Disconnect
Connection close notification with no payload.
Subscribe
Channel subscription request carrying a channel and accepted schema hashes.
SubscribeAck
Channel subscription success carrying a subscription id and selected schema.
SubscribeError
Channel subscription failure carrying a numeric reason and optional message.
Unsubscribe
Channel unsubscription request carrying the subscription id.
Publish
Publish request carrying a channel and typed message envelope.
idempotency_key is Some only when the PUBLISH_IDEMPOTENCY_KEY_FLAG
flag bit is set; it is the dedup-on-delivery key the server feeds to its
dedup cache. When None (and the flag clear) the frame is byte-identical
on the wire to a pre-13-L1 publish.
Fields
envelope: MessageEnvelopePublishAck
Publish success carrying the accepted message id.
PublishError
Publish failure carrying a numeric reason and optional message.
ConversationOpen
Conversation open carrying a conversation id and subject.
ConversationMessage
Conversation message carrying a conversation id and typed message envelope.
ConversationClose
Conversation close carrying a conversation id and optional reason.
Fields
ConversationError
Conversation failure carrying a conversation id, numeric reason, and optional message.
Accept
Backpressure acceptance for a delivered message.
Defer
Backpressure deferral for a buffered message.
Reject
Backpressure rejection for a shed message.
Ping
Connection keepalive ping.
Pong
Connection keepalive pong.
Push
Server-initiated push carrying a correlation id and an opaque payload.
A server writes this frame to a connected client over the client’s existing
connection (server-to-client, the inverse of every other request frame). The
correlation_id is the key the server uses to match the client’s later
Frame::PushReply back to this push; the payload is opaque application
bytes the server hands the client. This is an application-stream frame, so
stream_id is non-zero like a publish or conversation message.
PushReply
Client-initiated correlated reply to a Frame::Push.
After handling a pushed frame the client writes this back on the same
connection, echoing the push’s correlation_id so the server can match the
reply to the originating push. The payload is the client’s opaque answer.
WorkerRegister
Worker self-registration over an established connection.
A worker sends this control frame (stream 0) after the connection
handshake to announce its identity and routing dimensions. The server
associates the registration with the connection’s process id and surfaces
it to the application via the connection-notifier hook, then answers with a
Frame::WorkerRegisterAck. node is optional locality and is encoded
with a presence byte, never flattened to an empty string.
WorkerRegisterAck
Server acknowledgement of a Frame::WorkerRegister.
Carries the registration outcome: WorkerRegisterOutcome::Accepted when
the server (and any configured notifier) accepted the worker, or
WorkerRegisterOutcome::Rejected carrying a human-readable reason when it
did not. The acknowledgement is synchronous so a worker never believes it is
registered when the application rejected it.
Unknown
Forward-compatible frame preserved after length-delimited skipping.
Implementations§
Source§impl Frame
impl Frame
Sourcepub fn new_ping(stream_id: u32) -> Result<Self, ProtocolError>
pub fn new_ping(stream_id: u32) -> Result<Self, ProtocolError>
Construct a ping frame, enforcing the stream-0 control-frame invariant.
§Errors
Returns ProtocolError::InvalidStream when stream_id is not zero.
Sourcepub fn new_publish(
stream_id: u32,
channel: impl Into<String>,
envelope: MessageEnvelope,
) -> Result<Self, ProtocolError>
pub fn new_publish( stream_id: u32, channel: impl Into<String>, envelope: MessageEnvelope, ) -> Result<Self, ProtocolError>
Construct a publish frame, enforcing the non-zero application-stream invariant.
§Errors
Returns ProtocolError::InvalidStream when stream_id is zero.
Sourcepub fn new_publish_with_idempotency_key(
stream_id: u32,
channel: impl Into<String>,
envelope: MessageEnvelope,
idempotency_key: impl Into<String>,
) -> Result<Self, ProtocolError>
pub fn new_publish_with_idempotency_key( stream_id: u32, channel: impl Into<String>, envelope: MessageEnvelope, idempotency_key: impl Into<String>, ) -> Result<Self, ProtocolError>
Construct a publish frame carrying an idempotency key for dedup-on-delivery.
The returned frame has PUBLISH_IDEMPOTENCY_KEY_FLAG set and serializes
the trailing key field, so the server consults its dedup cache for this key.
§Errors
Returns ProtocolError::InvalidStream when stream_id is zero.
Sourcepub fn new_push(
stream_id: u32,
correlation_id: u64,
payload: Vec<u8>,
) -> Result<Self, ProtocolError>
pub fn new_push( stream_id: u32, correlation_id: u64, payload: Vec<u8>, ) -> Result<Self, ProtocolError>
Construct a server-to-client push frame, enforcing the non-zero application-stream invariant.
§Errors
Returns ProtocolError::InvalidStream when stream_id is zero.
Sourcepub fn new_push_reply(
stream_id: u32,
correlation_id: u64,
payload: Vec<u8>,
) -> Result<Self, ProtocolError>
pub fn new_push_reply( stream_id: u32, correlation_id: u64, payload: Vec<u8>, ) -> Result<Self, ProtocolError>
Construct a client-to-server push reply frame, echoing the correlation id of the originating push, and enforcing the non-zero application-stream invariant.
§Errors
Returns ProtocolError::InvalidStream when stream_id is zero.
Sourcepub const fn frame_type(&self) -> FrameType
pub const fn frame_type(&self) -> FrameType
Return the frame type represented by this frame body.
Trait Implementations§
impl Eq for Frame
impl StructuralPartialEq for Frame
Auto Trait Implementations§
impl Freeze for Frame
impl RefUnwindSafe for Frame
impl Send for Frame
impl Sync for Frame
impl Unpin for Frame
impl UnsafeUnpin for Frame
impl UnwindSafe for Frame
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.