pub struct DataItem { /* private fields */ }Expand description
Represents a data item with header information, names, a value payload, and a checksum for validation.
Implementations§
Source§impl DataItem
impl DataItem
Sourcepub fn item_size(&self) -> u32
pub fn item_size(&self) -> u32
Calculates the total binary size of the DataItem.
This includes the fixed header size, sizes of the group name, item name, value, and the checksum (2 bytes).
§Returns
- The full size of the item as a
u32value.
Sourcepub fn item_header(&self) -> &DataItemHeader
pub fn item_header(&self) -> &DataItemHeader
Provides a reference to the DataItemHeader of this item.
§Returns
- A reference to the contained
DataItemHeader.
Trait Implementations§
Source§impl FromStream for DataItem
impl FromStream for DataItem
Source§fn read_from<R>(&mut self, reader: &mut R) -> Result<(), Error>
fn read_from<R>(&mut self, reader: &mut R) -> Result<(), Error>
Reads a DataItem from a binary stream.
This method reads the header first, then if the status is not
Empty or Unknown, it reads the group name, item name,
value bytes, and checksum from the stream.
The group and item names are read as UTF-8 strings and exclude the trailing null byte.
§Parameters
reader: A mutable reference to a reader implementingReadandSeek.
§Returns
Ok(())if the item was read successfully.Err(Error)if any I/O error occurs or UTF-8 conversion fails.
Auto Trait Implementations§
impl Freeze for DataItem
impl RefUnwindSafe for DataItem
impl Send for DataItem
impl Sync for DataItem
impl Unpin for DataItem
impl UnwindSafe for DataItem
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
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>
Converts
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>
Converts
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