pub struct ExecutionContext {
pub engine_id: u64,
pub capabilities: Capabilities,
/* private fields */
}Expand description
Execution context passed to host functions.
Fields§
§engine_id: u64Engine ID for tracking.
capabilities: CapabilitiesCapabilities available to the script.
Implementations§
Source§impl ExecutionContext
impl ExecutionContext
Sourcepub fn new(
engine_id: u64,
capabilities: Capabilities,
limits: Limits,
sandbox: Sandbox,
) -> Self
pub fn new( engine_id: u64, capabilities: Capabilities, limits: Limits, sandbox: Sandbox, ) -> Self
Create a new execution context.
Sourcepub fn has_capability(&self, cap: Capability) -> bool
pub fn has_capability(&self, cap: Capability) -> bool
Check if a capability is granted.
Sourcepub fn require_capability(&self, cap: Capability) -> Result<()>
pub fn require_capability(&self, cap: Capability) -> Result<()>
Require a capability, returning an error if not granted.
Sourcepub fn record_instructions(&self, count: u64) -> Result<()>
pub fn record_instructions(&self, count: u64) -> Result<()>
Record instruction execution and check limits.
Sourcepub fn record_memory(&self, bytes: usize) -> Result<()>
pub fn record_memory(&self, bytes: usize) -> Result<()>
Record memory usage and check limits.
Sourcepub fn record_output(&self, bytes: usize) -> Result<()>
pub fn record_output(&self, bytes: usize) -> Result<()>
Record output and check limits.
Sourcepub fn record_fs_op(&self) -> Result<()>
pub fn record_fs_op(&self) -> Result<()>
Record filesystem operation and check limits.
Sourcepub fn record_net_op(&self) -> Result<()>
pub fn record_net_op(&self) -> Result<()>
Record network operation and check limits.
Sourcepub fn check_timeout(&self) -> Result<()>
pub fn check_timeout(&self) -> Result<()>
Check timeout and return error if exceeded.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Check if execution has been cancelled.
Sourcepub fn set_custom(&self, key: impl Into<String>, value: Value)
pub fn set_custom(&self, key: impl Into<String>, value: Value)
Set custom context data.
Sourcepub fn get_custom(&self, key: &str) -> Option<Value>
pub fn get_custom(&self, key: &str) -> Option<Value>
Get custom context data.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ExecutionContext
impl !RefUnwindSafe for ExecutionContext
impl Send for ExecutionContext
impl Sync for ExecutionContext
impl Unpin for ExecutionContext
impl UnwindSafe for ExecutionContext
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