pub struct FileScope { /* private fields */ }Expand description
Configurable allow-list for file:// opens.
Implementations§
Source§impl FileScope
impl FileScope
Sourcepub fn permissive() -> Self
pub fn permissive() -> Self
A scope that permits everything the process can read. Equivalent
to the default open_file behaviour. Useful
where the registry plumbing expects a FileScope but the caller
has no security policy to enforce.
Sourcepub fn allow_dir<P: AsRef<Path>>(self, dir: P) -> Self
pub fn allow_dir<P: AsRef<Path>>(self, dir: P) -> Self
Permit any path whose canonical form lives under dir.
The directory itself is canonicalised at insertion time, so
downstream resolution does not chase symlinks repeatedly.
Sourcepub fn resolve(&self, uri_str: &str) -> Result<PathBuf>
pub fn resolve(&self, uri_str: &str) -> Result<PathBuf>
Resolve a URI against the scope, returning the canonical absolute path on success.
Sourcepub fn open(&self, uri_str: &str) -> Result<Box<dyn BytesSource>>
pub fn open(&self, uri_str: &str) -> Result<Box<dyn BytesSource>>
Open uri_str under this scope.
Sourcepub fn register_into(self, registry: &mut SourceRegistry)
pub fn register_into(self, registry: &mut SourceRegistry)
Install this scope as the file:// driver of registry,
replacing any prior file registration. The scope is stored
in a process-global slot keyed by registry registration order;
subsequent register_into calls overwrite that slot.