pub struct BlockFrame {
pub block_type: u8,
pub flags: BlockFlags,
pub body: Vec<u8>,
}Expand description
Block frame — the wire envelope wrapping every block’s body.
┌──────────────────────────────────────────────────┐
│ block_type (varint, 1-2 bytes typically) │
│ block_flags (uint8, 1 byte) │
│ content_len (varint, 1-5 bytes typically) │
│ body [content_len bytes] │
└──────────────────────────────────────────────────┘Fields§
§block_type: u8The semantic block type (CODE=0x01, CONVERSATION=0x02, etc.).
flags: BlockFlagsPer-block flags.
body: Vec<u8>The raw body bytes (content_len bytes from the wire).
Implementations§
Source§impl BlockFrame
impl BlockFrame
Sourcepub fn write_to(&self, w: &mut impl Write) -> Result<usize, WireError>
pub fn write_to(&self, w: &mut impl Write) -> Result<usize, WireError>
Write this block frame to the provided writer.
Wire layout written:
- block_type as varint
- block_flags as single u8
- body.len() as varint (content_len)
- body bytes
§Returns
Total number of bytes written.
Sourcepub fn read_from(buf: &[u8]) -> Result<Option<(Self, usize)>, WireError>
pub fn read_from(buf: &[u8]) -> Result<Option<(Self, usize)>, WireError>
Read a block frame from the provided byte slice.
§Returns
Some((frame, bytes_consumed)) for normal blocks, or
None if the block type is END (0xFF), signaling the
end of the block stream.
§Errors
WireError::UnexpectedEofif the slice is too short.WireError::VarintTooLongif a varint is malformed.
Trait Implementations§
Source§impl Clone for BlockFrame
impl Clone for BlockFrame
Source§fn clone(&self) -> BlockFrame
fn clone(&self) -> BlockFrame
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BlockFrame
impl Debug for BlockFrame
Source§impl PartialEq for BlockFrame
impl PartialEq for BlockFrame
impl Eq for BlockFrame
impl StructuralPartialEq for BlockFrame
Auto Trait Implementations§
impl Freeze for BlockFrame
impl RefUnwindSafe for BlockFrame
impl Send for BlockFrame
impl Sync for BlockFrame
impl Unpin for BlockFrame
impl UnsafeUnpin for BlockFrame
impl UnwindSafe for BlockFrame
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