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: u16The number of the frame.
data: Vec<u8>The data within the frame.
is_last: boolWhether 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.
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§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more