pub struct BinaryEntry {
pub fid: FieldId,
pub tag: TypeTag,
pub value: BinaryValue,
}Expand description
A single field encoded in binary format
Fields§
§fid: FieldIdField identifier (16-bit unsigned integer)
tag: TypeTagType tag indicating value type
value: BinaryValueThe encoded value
Implementations§
Source§impl BinaryEntry
impl BinaryEntry
Sourcepub fn new(fid: FieldId, value: BinaryValue) -> Self
pub fn new(fid: FieldId, value: BinaryValue) -> Self
Creates a new binary entry
Sourcepub fn from_field(field: &LnmpField) -> Result<Self, BinaryError>
pub fn from_field(field: &LnmpField) -> Result<Self, BinaryError>
Creates a new binary entry from an LnmpField
§Errors
Returns BinaryError::InvalidValue if the field contains nested structures
(not supported in v0.4 binary format)
Sourcepub fn encode(&self) -> Vec<u8> ⓘ
pub fn encode(&self) -> Vec<u8> ⓘ
Encodes the entry to bytes
Binary layout:
┌──────────┬──────────┬──────────────────┐
│ FID │ THTAG │ VALUE │
│ (2 bytes)│ (1 byte) │ (variable) │
└──────────┴──────────┴──────────────────┘Sourcepub fn decode(bytes: &[u8]) -> Result<(Self, usize), BinaryError>
pub fn decode(bytes: &[u8]) -> Result<(Self, usize), BinaryError>
Decodes an entry from bytes
Returns a tuple of (BinaryEntry, bytes_consumed)
§Errors
Returns errors for:
UnexpectedEof: Insufficient dataInvalidTypeTag: Unknown type tagInvalidVarInt: Malformed VarIntInvalidUtf8: Invalid UTF-8 in stringInvalidValue: Other value decoding errors
Trait Implementations§
Source§impl Clone for BinaryEntry
impl Clone for BinaryEntry
Source§fn clone(&self) -> BinaryEntry
fn clone(&self) -> BinaryEntry
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 BinaryEntry
impl Debug for BinaryEntry
Source§impl PartialEq for BinaryEntry
impl PartialEq for BinaryEntry
impl StructuralPartialEq for BinaryEntry
Auto Trait Implementations§
impl Freeze for BinaryEntry
impl RefUnwindSafe for BinaryEntry
impl Send for BinaryEntry
impl Sync for BinaryEntry
impl Unpin for BinaryEntry
impl UnwindSafe for BinaryEntry
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