pub struct PluginSandbox { /* private fields */ }Expand description
Plugin sandbox
Implementations§
Source§impl PluginSandbox
impl PluginSandbox
Sourcepub fn new(
policy: SecurityPolicy,
limits: ResourceLimits,
permissions: Vec<Permission>,
) -> Self
pub fn new( policy: SecurityPolicy, limits: ResourceLimits, permissions: Vec<Permission>, ) -> Self
Create a new sandbox with policy and permissions
Sourcepub fn has_permission(&self, permission: &Permission) -> bool
pub fn has_permission(&self, permission: &Permission) -> bool
Check if a permission is granted
Sourcepub fn grant_permission(&mut self, permission: Permission)
pub fn grant_permission(&mut self, permission: Permission)
Grant a permission
Sourcepub fn revoke_permission(&mut self, permission: &Permission)
pub fn revoke_permission(&mut self, permission: &Permission)
Revoke a permission
Sourcepub fn is_host_allowed(&self, host: &str) -> bool
pub fn is_host_allowed(&self, host: &str) -> bool
Check if a host is allowed
Sourcepub fn is_path_allowed(&self, path: &PathBuf) -> bool
pub fn is_path_allowed(&self, path: &PathBuf) -> bool
Check if a path is allowed
Sourcepub fn limits(&self) -> &ResourceLimits
pub fn limits(&self) -> &ResourceLimits
Get resource limits
Sourcepub fn policy(&self) -> &SecurityPolicy
pub fn policy(&self) -> &SecurityPolicy
Get security policy
Sourcepub fn permissions(&self) -> &HashSet<Permission>
pub fn permissions(&self) -> &HashSet<Permission>
Get granted permissions
Sourcepub fn validate_call(
&self,
function: &HostFunction,
) -> Result<(), SecurityError>
pub fn validate_call( &self, function: &HostFunction, ) -> Result<(), SecurityError>
Validate a function call
Sourcepub fn validate_resources(
&self,
memory_used: usize,
fuel_consumed: Option<u64>,
) -> Result<(), SecurityError>
pub fn validate_resources( &self, memory_used: usize, fuel_consumed: Option<u64>, ) -> Result<(), SecurityError>
Validate resource usage
Trait Implementations§
Source§impl Clone for PluginSandbox
impl Clone for PluginSandbox
Source§fn clone(&self) -> PluginSandbox
fn clone(&self) -> PluginSandbox
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 PluginSandbox
impl Debug for PluginSandbox
Auto Trait Implementations§
impl Freeze for PluginSandbox
impl RefUnwindSafe for PluginSandbox
impl Send for PluginSandbox
impl Sync for PluginSandbox
impl Unpin for PluginSandbox
impl UnsafeUnpin for PluginSandbox
impl UnwindSafe for PluginSandbox
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more