Skip to main content

LocalScope

Struct LocalScope 

Source
pub struct LocalScope { /* private fields */ }

Implementations§

Source§

impl LocalScope

Source

pub fn new(allowed: &[PathBuf]) -> Self

Roots are canonicalised now so symlinked roots still compare equal to canonicalised requests, and their identity is recorded. A root that does not exist yet is kept as written and simply never matches.

Source

pub fn roots(&self) -> &[PathBuf]

Source

pub fn is_empty(&self) -> bool

Source

pub fn resolve_existing(&self, raw: &str) -> Result<PathBuf>

Resolve a model-supplied path to a canonical path inside a root. Symlinks are followed before the containment check, so a link pointing outside the allowed directories is refused.

Source

pub fn resolve_for_write(&self, raw: &str) -> Result<PathBuf>

Resolve a path that may not exist yet (a download target). The nearest existing ancestor must be inside a root.

Source

pub fn open_file(&self, raw: &str) -> Result<(PathBuf, File)>

Resolve and open a regular file for reading.

Source

pub fn open_resolved(&self, path: &Path) -> Result<File>

Open the regular file at path, a path inside a root as resolve_existing or a walk below one returns it, without following a symlink anywhere below the root.

Source

pub fn list(&self, dir: &Path) -> Result<Vec<LocalEntry>>

List the directory at dir, a path inside a root.

Source

pub fn create_part(&self, dest: &Path) -> Result<PartFile>

Start a download to dest (as resolve_for_write returns it): missing folders are created, and the data goes to a randomly named temporary file created exclusively in the destination folder. PartFile::commit renames it into place.

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more