Skip to main content

ExprArena

Struct ExprArena 

Source
pub struct ExprArena { /* private fields */ }
Expand description

An arena-based allocator for EventQL expressions.

The ExprArena provides a memory-efficient way to store and manage AST nodes by using a flat vector and returning lightweight ExprRef handles.

Implementations§

Source§

impl ExprArena

Source

pub fn alloc(&mut self, attrs: Attrs, value: Value) -> ExprRef

Allocates a new expression in the arena.

This method takes an expression’s attributes and value, hashes the value to create a stable ExprKey, and stores it in the arena. It returns an ExprRef which can be used to retrieve the expression later.

Source

pub fn get(&self, node_ref: ExprRef) -> Expr

Retrieves a node from the arena using an ExprRef.

§Panics

Panics if the ExprRef contains an invalid pointer that is out of bounds of the arena’s internal storage.

Source

pub fn alloc_vec(&mut self, values: Vec<ExprRef>) -> VecRef

Allocates a vector of expression references and returns a VecRef handle.

Source

pub fn alloc_rec(&mut self, values: Vec<Field>) -> RecRef

Allocates a vector of record fields and returns a RecRef handle.

Source

pub fn vec(&self, ptr: VecRef) -> &[ExprRef]

Returns the slice of expression references for the given VecRef.

Source

pub fn vec_get(&self, ptr: VecRef, idx: usize) -> ExprRef

Returns the expression reference at index idx within the given VecRef.

Source

pub fn vec_idxes(&self, ptr: VecRef) -> impl Iterator<Item = usize> + use<>

Returns an iterator over valid indices for the given VecRef.

Source

pub fn rec(&self, ptr: RecRef) -> &Vec<Field>

Returns the vector of fields for the given RecRef.

Source

pub fn rec_get(&self, ptr: RecRef, idx: usize) -> Field

Returns the field at index idx within the given RecRef.

Source

pub fn rec_idxes(&self, ptr: RecRef) -> impl Iterator<Item = usize> + use<>

Returns an iterator over valid indices for the given RecRef.

Trait Implementations§

Source§

impl Default for ExprArena

Source§

fn default() -> ExprArena

Returns the “default value” for a type. Read more
Source§

impl Serialize for ExprArena

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.