#[non_exhaustive]pub enum IndirectAdjustmentOp {
Add,
Mul,
Div,
Mod,
And,
Or,
Xor,
}Expand description
Arithmetic operation applied to the value read at an indirect offset’s
base_offset before the result is used as the final file offset.
magic(5) supports +, -, *, /, %, &, |, and ^ between the
pointer-type specifier and the operand inside the parentheses. Addition
and subtraction collapse to IndirectAdjustmentOp::Add with a signed
adjustment (so (N.X-1) is Add(-1) rather than a separate Sub
variant); the remaining operators each have a dedicated variant.
The default is IndirectAdjustmentOp::Add; an indirect offset with no
arithmetic — just (base.type) — is encoded as Add with adjustment: 0, preserving backwards compatibility.
§Examples
use libmagic_rs::parser::ast::IndirectAdjustmentOp;
assert_eq!(IndirectAdjustmentOp::default(), IndirectAdjustmentOp::Add);Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Add
Addition (also covers subtraction via negative adjustment).
§Examples
use libmagic_rs::parser::ast::IndirectAdjustmentOp;
assert_eq!(IndirectAdjustmentOp::default(), IndirectAdjustmentOp::Add);Mul
Multiplication: pointer_value * adjustment.
§Examples
use libmagic_rs::parser::ast::IndirectAdjustmentOp;
let op = IndirectAdjustmentOp::Mul;
assert_eq!(op, IndirectAdjustmentOp::Mul);Div
Truncating integer division: pointer_value / adjustment. Division
by zero is rejected by the evaluator with an error.
§Examples
use libmagic_rs::parser::ast::IndirectAdjustmentOp;
let op = IndirectAdjustmentOp::Div;
assert_eq!(op, IndirectAdjustmentOp::Div);Mod
Remainder: pointer_value % adjustment. Modulo by zero is rejected
by the evaluator with an error.
§Examples
use libmagic_rs::parser::ast::IndirectAdjustmentOp;
let op = IndirectAdjustmentOp::Mod;
assert_eq!(op, IndirectAdjustmentOp::Mod);And
Bitwise AND: pointer_value & adjustment.
§Examples
use libmagic_rs::parser::ast::IndirectAdjustmentOp;
let op = IndirectAdjustmentOp::And;
assert_eq!(op, IndirectAdjustmentOp::And);Or
Bitwise OR: pointer_value | adjustment.
§Examples
use libmagic_rs::parser::ast::IndirectAdjustmentOp;
let op = IndirectAdjustmentOp::Or;
assert_eq!(op, IndirectAdjustmentOp::Or);Xor
Bitwise XOR: pointer_value ^ adjustment.
§Examples
use libmagic_rs::parser::ast::IndirectAdjustmentOp;
let op = IndirectAdjustmentOp::Xor;
assert_eq!(op, IndirectAdjustmentOp::Xor);Trait Implementations§
Source§impl Clone for IndirectAdjustmentOp
impl Clone for IndirectAdjustmentOp
Source§fn clone(&self) -> IndirectAdjustmentOp
fn clone(&self) -> IndirectAdjustmentOp
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more