Skip to main content

PathPolicy

Trait PathPolicy 

Source
pub trait PathPolicy:
    Send
    + Sync
    + 'static {
    // Required method
    fn resolve(&self, path: &Path, op: PathOp) -> Result<FsAccess, PolicyError>;

    // Provided method
    fn policy_name(&self) -> &'static str { ... }
}
Expand description

Policy that decides whether a given path may be accessed.

Every filesystem-touching function in mlua-batteries calls PathPolicy::resolve before performing I/O.

Required Methods§

Source

fn resolve(&self, path: &Path, op: PathOp) -> Result<FsAccess, PolicyError>

Validate path for op and return an FsAccess handle.

Return Ok(handle) to allow, Err(reason) to deny.

Provided Methods§

Source

fn policy_name(&self) -> &'static str

Human-readable name for this policy, used in Debug output.

The default implementation returns std::any::type_name of the concrete type, which works correctly even through trait objects because the vtable dispatches to the concrete implementation.

Implementors§