pub struct ClientFrame { /* private fields */ }Expand description
A length-prefixed external client frame.
The wire shape is:
u32 body_len_be | u16 protocol_version_be | payload bytesbody_len includes the version field and the payload. Unknown future
protocol versions are rejected loud, matching RULES R-3/R-4.
Implementations§
Source§impl ClientFrame
impl ClientFrame
Sourcepub fn from_message(
message: &ClientWireMessage,
) -> Result<Self, ClientProtocolError>
pub fn from_message( message: &ClientWireMessage, ) -> Result<Self, ClientProtocolError>
Encode a typed wire message as this frame payload.
Sourcepub fn with_version(protocol_version: u16, payload: impl Into<Bytes>) -> Self
pub fn with_version(protocol_version: u16, payload: impl Into<Bytes>) -> Self
Build a frame with an explicit protocol version for compatibility tests.
Sourcepub fn protocol_version(&self) -> u16
pub fn protocol_version(&self) -> u16
Return the frame protocol version.
Sourcepub fn encode(&self) -> Result<Bytes, ClientProtocolError>
pub fn encode(&self) -> Result<Bytes, ClientProtocolError>
Encode the frame with a big-endian length prefix.
Sourcepub fn decode_message(&self) -> Result<ClientWireMessage, ClientProtocolError>
pub fn decode_message(&self) -> Result<ClientWireMessage, ClientProtocolError>
Decode the frame payload as a typed wire message.
Trait Implementations§
Source§impl Clone for ClientFrame
impl Clone for ClientFrame
Source§fn clone(&self) -> ClientFrame
fn clone(&self) -> ClientFrame
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ClientFrame
impl Debug for ClientFrame
impl Eq for ClientFrame
Source§impl PartialEq for ClientFrame
impl PartialEq for ClientFrame
Source§fn eq(&self, other: &ClientFrame) -> bool
fn eq(&self, other: &ClientFrame) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ClientFrame
Auto Trait Implementations§
impl !Freeze for ClientFrame
impl RefUnwindSafe for ClientFrame
impl Send for ClientFrame
impl Sync for ClientFrame
impl Unpin for ClientFrame
impl UnsafeUnpin for ClientFrame
impl UnwindSafe for ClientFrame
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
Mutably borrows from an owned value. Read more