pub struct Frame {
pub id: [u8; 16],
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: [u8; 16]
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: [u8; 16],
number: u16,
data: Vec<u8>,
is_last: bool,
) -> Frame
pub const fn new( id: [u8; 16], number: u16, data: Vec<u8>, is_last: bool, ) -> Frame
Creates a new Frame.
Sourcepub fn decode(encoded: &[u8]) -> Result<(usize, Frame), FrameDecodingError>
pub fn decode(encoded: &[u8]) -> Result<(usize, Frame), FrameDecodingError>
Decode a frame from a byte vector.
Sourcepub fn parse_frame(
data: &[u8],
start: usize,
) -> Result<(usize, Frame), FrameDecodingError>
pub fn parse_frame( data: &[u8], start: usize, ) -> Result<(usize, Frame), 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<Frame>, FrameParseError>
pub fn parse_frames(encoded: &[u8]) -> Result<Vec<Frame>, 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.