pub struct Frame {
pub stream_id: u32,
pub sequence: u32,
pub flags: FrameFlags,
pub payload: Bytes,
}Expand description
Protocol frame structure
Fields§
§stream_id: u32Stream identifier
sequence: u32Sequence number
flags: FrameFlagsFrame flags
payload: BytesFrame payload
Implementations§
Source§impl Frame
impl Frame
Sourcepub fn new(
stream_id: u32,
sequence: u32,
flags: FrameFlags,
payload: Bytes,
) -> Self
pub fn new( stream_id: u32, sequence: u32, flags: FrameFlags, payload: Bytes, ) -> Self
Create a new frame
Sourcepub fn end_stream(stream_id: u32, sequence: u32) -> Self
pub fn end_stream(stream_id: u32, sequence: u32) -> Self
Create an end-of-stream frame
Sourcepub fn to_msgpack(&self) -> Result<Vec<u8>, ProtocolError>
pub fn to_msgpack(&self) -> Result<Vec<u8>, ProtocolError>
Serialize frame to MessagePack bytes
Sourcepub fn from_msgpack(bytes: &[u8]) -> Result<Self, ProtocolError>
pub fn from_msgpack(bytes: &[u8]) -> Result<Self, ProtocolError>
Deserialize frame from MessagePack bytes
Sourcepub fn payload_size(&self) -> usize
pub fn payload_size(&self) -> usize
Get the payload size
Sourcepub fn is_end_stream(&self) -> bool
pub fn is_end_stream(&self) -> bool
Check if this is an end-of-stream frame
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Frame
impl<'de> Deserialize<'de> for Frame
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl !Freeze for Frame
impl RefUnwindSafe for Frame
impl Send for Frame
impl Sync for Frame
impl Unpin 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
Mutably borrows from an owned value. Read more