pub struct Frame {
pub envelope_version: u32,
pub kind: i32,
pub payload_protocol: u32,
pub payload: Vec<u8>,
pub request_id: u64,
pub payload_encoding: i32,
pub deadline_unix_ms: u64,
pub traceparent: String,
pub tracestate: String,
}Expand description
Every control-plane frame on a broker connection.
Fields§
§envelope_version: u32ALWAYS 1 in v1 broker. Frozen.
kind: i32§payload_protocol: u320x00 for Hello/HelloReply; 0xAD01 for admin verbs
payload: Vec<u8>OPAQUE for non-control kinds
request_id: u64§payload_encoding: i32§deadline_unix_ms: u64§traceparent: StringW3C trace context
tracestate: StringImplementations§
Source§impl Frame
impl Frame
Sourcepub fn kind(&self) -> FrameKind
pub fn kind(&self) -> FrameKind
Returns the enum value of kind, or the default if the field is set to an invalid enum value.
Sourcepub fn payload_encoding(&self) -> PayloadEncoding
pub fn payload_encoding(&self) -> PayloadEncoding
Returns the enum value of payload_encoding, or the default if the field is set to an invalid enum value.
Sourcepub fn set_payload_encoding(&mut self, value: PayloadEncoding)
pub fn set_payload_encoding(&mut self, value: PayloadEncoding)
Sets payload_encoding to the provided enum value.
Source§impl Frame
impl Frame
Sourcepub fn request(payload_protocol: u32, payload: Vec<u8>) -> Self
pub fn request(payload_protocol: u32, payload: Vec<u8>) -> Self
Build a v1 request frame with correct envelope defaults.
Sets envelope_version to PROTOCOL_VERSION, kind to
REQUEST, payload_encoding to NONE, no deadline, and empty
trace context. Callers correlate request/response pairs through
request_id (see Frame::with_request_id).
use running_process::broker::protocol::Frame;
let frame = Frame::request(0x7A63, b"payload".to_vec()).with_request_id(7);
assert_eq!(frame.envelope_version, 1);
assert_eq!(frame.request_id, 7);Sourcepub fn response_to(request: &Self, payload: Vec<u8>) -> Self
pub fn response_to(request: &Self, payload: Vec<u8>) -> Self
Build the v1 response frame for request.
Echoes the request’s payload_protocol, request_id, and trace
context, sets kind to RESPONSE, and carries payload.
use running_process::broker::protocol::Frame;
let request = Frame::request(0x7A63, b"ping".to_vec()).with_request_id(9);
let response = Frame::response_to(&request, b"pong".to_vec());
assert_eq!(response.request_id, 9);
assert_eq!(response.payload_protocol, 0x7A63);Sourcepub fn with_request_id(self, request_id: u64) -> Self
pub fn with_request_id(self, request_id: u64) -> Self
Set the correlation request_id (builder style).
Trait Implementations§
impl Eq for Frame
Source§impl Message for Frame
impl Message for Frame
Source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Source§fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
Source§fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Source§fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
Source§fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Source§fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
Source§fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
Source§fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self. Read moreSource§fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self.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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more