ExecutionContext

Struct ExecutionContext 

Source
pub struct ExecutionContext {
    pub engine_id: u64,
    pub capabilities: Capabilities,
    /* private fields */
}
Expand description

Execution context passed to host functions.

Fields§

§engine_id: u64

Engine ID for tracking.

§capabilities: Capabilities

Capabilities available to the script.

Implementations§

Source§

impl ExecutionContext

Source

pub fn new( engine_id: u64, capabilities: Capabilities, limits: Limits, sandbox: Sandbox, ) -> Self

Create a new execution context.

Source

pub fn has_capability(&self, cap: Capability) -> bool

Check if a capability is granted.

Source

pub fn require_capability(&self, cap: Capability) -> Result<()>

Require a capability, returning an error if not granted.

Source

pub fn sandbox(&self) -> &Sandbox

Get the sandbox for permission checks.

Source

pub fn record_instructions(&self, count: u64) -> Result<()>

Record instruction execution and check limits.

Source

pub fn record_memory(&self, bytes: usize) -> Result<()>

Record memory usage and check limits.

Source

pub fn record_output(&self, bytes: usize) -> Result<()>

Record output and check limits.

Source

pub fn record_fs_op(&self) -> Result<()>

Record filesystem operation and check limits.

Source

pub fn record_net_op(&self) -> Result<()>

Record network operation and check limits.

Source

pub fn check_timeout(&self) -> Result<()>

Check timeout and return error if exceeded.

Source

pub fn elapsed(&self) -> Duration

Get elapsed time since execution started.

Source

pub fn is_cancelled(&self) -> bool

Check if execution has been cancelled.

Source

pub fn cancel(&self)

Cancel execution.

Source

pub fn set_custom(&self, key: impl Into<String>, value: Value)

Set custom context data.

Source

pub fn get_custom(&self, key: &str) -> Option<Value>

Get custom context data.

Source

pub fn reset(&self, limits: Limits)

Reset the context for a new execution.

Trait Implementations§

Source§

impl Debug for ExecutionContext

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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.