pub struct Field<T> {
pub value: T,
pub offset: usize,
pub size: usize,
}Expand description
A parsed value together with its absolute offset and on-disk width in the file buffer.
Fields§
§value: TDecoded value (may be promoted, e.g. u32 stored as u64).
offset: usizeAbsolute byte offset from the start of the file buffer.
size: usizeWidth of this field in the on-disk representation, in bytes.
Implementations§
Source§impl Field<u64>
impl Field<u64>
Sourcepub fn update(
&mut self,
buffer: &mut [u8],
new_value: u64,
) -> Result<(), FileParseError>
pub fn update( &mut self, buffer: &mut [u8], new_value: u64, ) -> Result<(), FileParseError>
Updates the buffer at the specified offset with the new value for u64.
Sourcepub fn update_with(
&mut self,
buffer: &mut [u8],
new_value: u64,
order: ByteOrder,
) -> Result<(), FileParseError>
pub fn update_with( &mut self, buffer: &mut [u8], new_value: u64, order: ByteOrder, ) -> Result<(), FileParseError>
Updates the buffer using the specified byte order.
Source§impl Field<u32>
impl Field<u32>
Sourcepub fn update(
&mut self,
buffer: &mut [u8],
new_value: u32,
) -> Result<(), FileParseError>
pub fn update( &mut self, buffer: &mut [u8], new_value: u32, ) -> Result<(), FileParseError>
Updates the buffer at the specified offset with the new value for u32.
Sourcepub fn update_with(
&mut self,
buffer: &mut [u8],
new_value: u32,
order: ByteOrder,
) -> Result<(), FileParseError>
pub fn update_with( &mut self, buffer: &mut [u8], new_value: u32, order: ByteOrder, ) -> Result<(), FileParseError>
Updates the buffer using the specified byte order.
Source§impl Field<u8>
impl Field<u8>
Sourcepub fn update(
&mut self,
buffer: &mut [u8],
new_value: u8,
) -> Result<(), FileParseError>
pub fn update( &mut self, buffer: &mut [u8], new_value: u8, ) -> Result<(), FileParseError>
Writes a single byte at Field::offset.
Source§impl<const N: usize> Field<FixedBytes<N>>
impl<const N: usize> Field<FixedBytes<N>>
Sourcepub fn update(
&mut self,
buffer: &mut [u8],
new_value: &[u8],
) -> Result<(), FileParseError>
pub fn update( &mut self, buffer: &mut [u8], new_value: &[u8], ) -> Result<(), FileParseError>
Replaces the raw bytes, zero-padding to Field::size.
Sourcepub fn update_str(
&mut self,
buffer: &mut [u8],
new_value: &str,
) -> Result<(), FileParseError>
pub fn update_str( &mut self, buffer: &mut [u8], new_value: &str, ) -> Result<(), FileParseError>
Convenience wrapper around update for UTF-8 strings.
Source§impl Field<u16>
impl Field<u16>
Sourcepub fn update(
&mut self,
buffer: &mut [u8],
new_value: u16,
) -> Result<(), FileParseError>
pub fn update( &mut self, buffer: &mut [u8], new_value: u16, ) -> Result<(), FileParseError>
Updates the buffer at the specified offset with the new value for u16.
Sourcepub fn update_with(
&mut self,
buffer: &mut [u8],
new_value: u16,
order: ByteOrder,
) -> Result<(), FileParseError>
pub fn update_with( &mut self, buffer: &mut [u8], new_value: u16, order: ByteOrder, ) -> Result<(), FileParseError>
Updates the buffer using the specified byte order.