pub enum OffsetSpec {
Absolute(i64),
Indirect {
base_offset: i64,
pointer_type: TypeKind,
adjustment: i64,
endian: Endianness,
},
Relative(i64),
FromEnd(i64),
}Expand description
Offset specification for locating data in files
Variants§
Absolute(i64)
Absolute offset from file start (or from file end if negative)
Positive values are offsets from the start of the file.
Negative values are offsets from the end of the file (same as FromEnd).
§Examples
use libmagic_rs::parser::ast::OffsetSpec;
let offset = OffsetSpec::Absolute(0x10); // Read at byte 16 from start
let from_end = OffsetSpec::Absolute(-4); // 4 bytes before end of fileIndirect
Indirect offset through pointer dereferencing
Reads a pointer value at base_offset, interprets it according to pointer_type
and endian, then adds adjustment to get the final offset.
§Examples
use libmagic_rs::parser::ast::{OffsetSpec, TypeKind, Endianness};
let indirect = OffsetSpec::Indirect {
base_offset: 0x20,
pointer_type: TypeKind::Long { endian: Endianness::Little, signed: false },
adjustment: 4,
endian: Endianness::Little,
};Fields
§
endian: EndiannessEndianness for pointer reading
Relative(i64)
Relative offset from previous match position
§Examples
use libmagic_rs::parser::ast::OffsetSpec;
let relative = OffsetSpec::Relative(8); // 8 bytes after previous matchFromEnd(i64)
Offset from end of file (negative values move towards start)
§Examples
use libmagic_rs::parser::ast::OffsetSpec;
let from_end = OffsetSpec::FromEnd(-16); // 16 bytes before end of fileTrait Implementations§
Source§impl Clone for OffsetSpec
impl Clone for OffsetSpec
Source§fn clone(&self) -> OffsetSpec
fn clone(&self) -> OffsetSpec
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 OffsetSpec
impl Debug for OffsetSpec
Source§impl<'de> Deserialize<'de> for OffsetSpec
impl<'de> Deserialize<'de> for OffsetSpec
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for OffsetSpec
impl PartialEq for OffsetSpec
Source§impl Serialize for OffsetSpec
impl Serialize for OffsetSpec
impl Eq for OffsetSpec
impl StructuralPartialEq for OffsetSpec
Auto Trait Implementations§
impl Freeze for OffsetSpec
impl RefUnwindSafe for OffsetSpec
impl Send for OffsetSpec
impl Sync for OffsetSpec
impl Unpin for OffsetSpec
impl UnsafeUnpin for OffsetSpec
impl UnwindSafe for OffsetSpec
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