Trait codec_sv2::Frame [−][src]
pub trait Frame<'a, T> where
T: Encodable + GetSize, { type Buffer: AsMut<[u8]>; type Deserialized; fn serialize(self, dst: &mut Self::Buffer) -> Result<(), Error>; fn payload(&'a mut self) -> &'a mut [u8]; fn get_header(&self) -> Option<Header>; fn from_bytes(bytes: Self::Buffer) -> Result<Self, isize>; fn from_bytes_unchecked(bytes: Self::Buffer) -> Self; fn size_hint(bytes: &[u8]) -> isize; fn encoded_length(&self) -> usize; fn from_message(
message: T,
message_type: u8,
extension_type: u16
) -> Option<Self>; }
Associated Types
Required methods
Serialize the frame into dst if the frame is already serialized it just swap dst with itself
fn deserialize(&’a mut self) -> Result<Self::Deserialized, serde_sv2::Error>;
fn get_header(&self) -> Option<Header>
fn get_header(&self) -> Option<Header>
If is an Sv2 frame return the Some(header) if it is a noise frame return None
fn from_bytes(bytes: Self::Buffer) -> Result<Self, isize>
fn from_bytes(bytes: Self::Buffer) -> Result<Self, isize>
Try to build an Frame frame from raw bytes. It return the frame or the number of the bytes needed to complete the frame The resulting frame is just a header plus a payload with the right number of bytes nothing is said about the correctness of the payload
fn from_bytes_unchecked(bytes: Self::Buffer) -> Self
fn encoded_length(&self) -> usize
fn from_message(
message: T,
message_type: u8,
extension_type: u16
) -> Option<Self>
fn from_message(
message: T,
message_type: u8,
extension_type: u16
) -> Option<Self>
Try to build an Frame frame from a serializable payload. It return a Frame if the size of the payload fit in the frame, if not it return None
Implementations on Foreign Types
Serialize the frame into dst if the frame is already serialized it just swap dst with itself
If is an Sv2 frame return the Some(header) if it is a noise frame return None
pub fn from_bytes(
_bytes: <NoiseFrame as Frame<'a, Vec<u8, Global>>>::Buffer
) -> Result<NoiseFrame, isize>
pub fn from_bytes(
_bytes: <NoiseFrame as Frame<'a, Vec<u8, Global>>>::Buffer
) -> Result<NoiseFrame, isize>
Try to build a Frame frame from raw bytes. It return the frame or the number of the bytes needed to complete the frame The resulting frame is just a header plus a payload with the right number of bytes nothing is said about the correctness of the payload
pub fn from_message(
message: Vec<u8, Global>,
_message_type: u8,
_extension_type: u16
) -> Option<NoiseFrame>
pub fn from_message(
message: Vec<u8, Global>,
_message_type: u8,
_extension_type: u16
) -> Option<NoiseFrame>
Try to build an Frame frame from a serializable payload. It return a Frame if the size of the payload fit in the frame, if not it return None Inneficient should be used only to build HandShakeFrames
type Deserialized = &'a mut [u8]
pub fn from_bytes_unchecked(
bytes: <NoiseFrame as Frame<'a, Vec<u8, Global>>>::Buffer
) -> NoiseFrame