pub enum ComputedExpr {
Show 20 variants
FieldRef {
path: String,
},
UnwrapOr {
expr: Box<ComputedExpr>,
default: Value,
},
Binary {
op: BinaryOp,
left: Box<ComputedExpr>,
right: Box<ComputedExpr>,
},
Cast {
expr: Box<ComputedExpr>,
to_type: String,
},
MethodCall {
expr: Box<ComputedExpr>,
method: String,
args: Vec<ComputedExpr>,
},
Literal {
value: Value,
},
Paren {
expr: Box<ComputedExpr>,
},
Var {
name: String,
},
Let {
name: String,
value: Box<ComputedExpr>,
body: Box<ComputedExpr>,
},
If {
condition: Box<ComputedExpr>,
then_branch: Box<ComputedExpr>,
else_branch: Box<ComputedExpr>,
},
None,
Some {
value: Box<ComputedExpr>,
},
Slice {
expr: Box<ComputedExpr>,
start: usize,
end: usize,
},
Index {
expr: Box<ComputedExpr>,
index: usize,
},
U64FromLeBytes {
bytes: Box<ComputedExpr>,
},
U64FromBeBytes {
bytes: Box<ComputedExpr>,
},
ByteArray {
bytes: Vec<u8>,
},
Closure {
param: String,
body: Box<ComputedExpr>,
},
Unary {
op: UnaryOp,
expr: Box<ComputedExpr>,
},
JsonToBytes {
expr: Box<ComputedExpr>,
},
}Expand description
AST for computed field expressions Supports a subset of Rust expressions needed for computed fields:
- Field references (possibly from other sections)
- Unwrap with defaults
- Basic arithmetic and comparisons
- Type casts
- Method calls
- Let bindings and conditionals
- Byte array operations
Variants§
FieldRef
Reference to a field: “field_name” or “section.field_name”
UnwrapOr
Unwrap with default: expr.unwrap_or(default)
Binary
Binary operation: left op right
Cast
Type cast: expr as type
MethodCall
Method call: expr.method(args)
Literal
Literal value: numbers, booleans, strings
Paren
Parenthesized expression for grouping
Fields
§
expr: Box<ComputedExpr>Var
Let
If
None
Some
Fields
§
value: Box<ComputedExpr>Slice
Index
U64FromLeBytes
Fields
§
bytes: Box<ComputedExpr>U64FromBeBytes
Fields
§
bytes: Box<ComputedExpr>ByteArray
Closure
Unary
JsonToBytes
Fields
§
expr: Box<ComputedExpr>Trait Implementations§
Source§impl Clone for ComputedExpr
impl Clone for ComputedExpr
Source§fn clone(&self) -> ComputedExpr
fn clone(&self) -> ComputedExpr
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 ComputedExpr
impl Debug for ComputedExpr
Source§impl<'de> Deserialize<'de> for ComputedExpr
impl<'de> Deserialize<'de> for ComputedExpr
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
Auto Trait Implementations§
impl Freeze for ComputedExpr
impl RefUnwindSafe for ComputedExpr
impl Send for ComputedExpr
impl Sync for ComputedExpr
impl Unpin for ComputedExpr
impl UnwindSafe for ComputedExpr
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