pub struct Frame {
pub id: ChannelId,
pub number: u16,
pub data: Vec<u8>,
pub is_last: bool,
}
Expand description
A channel frame is a segment of a channel’s data.
Encoding
frame = channel_id ++ frame_number ++ frame_data_length ++ frame_data ++ is_last
- channel_id = bytes16
- frame_number = uint16
- frame_data_length = uint32
- frame_data = bytes
- is_last = bool
Fields§
§id: ChannelId
The unique idetifier for the frame.
number: u16
The number of the frame.
data: Vec<u8>
The data within the frame.
is_last: bool
Whether or not the frame is the last in the sequence.
Implementations§
Source§impl Frame
impl Frame
Sourcepub const fn new(
id: ChannelId,
number: u16,
data: Vec<u8>,
is_last: bool,
) -> Self
pub const fn new( id: ChannelId, number: u16, data: Vec<u8>, is_last: bool, ) -> Self
Creates a new Frame.
Sourcepub fn decode(encoded: &[u8]) -> Result<(usize, Self), FrameDecodingError>
pub fn decode(encoded: &[u8]) -> Result<(usize, Self), FrameDecodingError>
Decode a frame from a byte vector.
Sourcepub fn parse_frame(
data: &[u8],
start: usize,
) -> Result<(usize, Self), FrameDecodingError>
pub fn parse_frame( data: &[u8], start: usize, ) -> Result<(usize, Self), FrameDecodingError>
Parses a single frame from the given data at the given starting position, returning the frame and the number of bytes consumed.
Sourcepub fn parse_frames(encoded: &[u8]) -> Result<Vec<Self>, FrameParseError>
pub fn parse_frames(encoded: &[u8]) -> Result<Vec<Self>, FrameParseError>
Parse the on chain serialization of frame(s) in an L1 transaction. Currently only version 0 of the serialization format is supported. All frames must be parsed without error and there must not be any left over data and there must be at least one frame.
Frames are stored in L1 transactions with the following format:
data = DerivationVersion0 ++ Frame(s)
Where there is one or more frames concatenated together.
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 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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)