pub struct BinaryFrame { /* private fields */ }Expand description
Binary frame representing a complete LNMP record
Implementations§
Source§impl BinaryFrame
impl BinaryFrame
Sourcepub fn new(entries: Vec<BinaryEntry>) -> Self
pub fn new(entries: Vec<BinaryEntry>) -> Self
Creates a new frame with version 0x04 and flags 0x00
§Arguments
entries- Vector of binary entries (should be sorted by FID for canonical form)
Sourcepub fn encode(&self) -> Vec<u8> ⓘ
pub fn encode(&self) -> Vec<u8> ⓘ
Encodes the frame to bytes
Binary layout:
- VERSION (1 byte): 0x04
- FLAGS (1 byte): 0x00
- ENTRY_COUNT (VarInt): Number of entries
- ENTRIES: Each entry encoded sequentially
Sourcepub fn decode(bytes: &[u8]) -> Result<Self, BinaryError>
pub fn decode(bytes: &[u8]) -> Result<Self, BinaryError>
Decodes a frame from bytes
§Errors
Returns errors for:
UnexpectedEof: Insufficient dataUnsupportedVersion: Version byte is not 0x04InvalidVarInt: Malformed entry count- Entry decoding errors
Sourcepub fn decode_allow_unsorted(bytes: &[u8]) -> Result<Self, BinaryError>
pub fn decode_allow_unsorted(bytes: &[u8]) -> Result<Self, BinaryError>
Decodes binary frame without enforcing canonical FID ordering.
Sourcepub fn to_record(&self) -> LnmpRecord
pub fn to_record(&self) -> LnmpRecord
Converts to LnmpRecord
Sourcepub fn from_record(record: &LnmpRecord) -> Result<Self, BinaryError>
pub fn from_record(record: &LnmpRecord) -> Result<Self, BinaryError>
Creates from LnmpRecord, sorting fields by FID
§Errors
Returns BinaryError::InvalidValue if any field contains nested structures
(not supported in v0.4 binary format)
Trait Implementations§
Source§impl Clone for BinaryFrame
impl Clone for BinaryFrame
Source§fn clone(&self) -> BinaryFrame
fn clone(&self) -> BinaryFrame
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 BinaryFrame
impl Debug for BinaryFrame
Source§impl PartialEq for BinaryFrame
impl PartialEq for BinaryFrame
impl StructuralPartialEq for BinaryFrame
Auto Trait Implementations§
impl Freeze for BinaryFrame
impl RefUnwindSafe for BinaryFrame
impl Send for BinaryFrame
impl Sync for BinaryFrame
impl Unpin for BinaryFrame
impl UnwindSafe for BinaryFrame
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