Skip to main content

PathManager

Struct PathManager 

Source
pub struct PathManager<'a> { /* private fields */ }
Expand description

A safe interface to the path handling features.

This struct is constructed from the three path handling features, MakePath, MapPath, and FreePath, and exposes them as one safe interface.

Please take a look at the module documentation for a usage example.

Implementations§

Source§

impl<'a> PathManager<'a>

Source

pub fn new(make: MakePath<'a>, map: MapPath<'a>, free: FreePath<'a>) -> Self

Create a new path manager from the three path handling features.

Source

pub fn allocate_path( &mut self, relative_path: &Path, ) -> Result<(ManagedPath<'a>, ManagedStr<'a>), StateErr>

Allocate a new path.

This function maps the given relative file path to an absolute file path as well as an abstract file path. The absolute file path can be used to access the new file and the abstract file path is used to reference it in the state of the plugin. Storing the absolute file path in the plugin state will not work since it might have changed when the state is restored.

The relative file path will be the suffix of the absolute file path and will be contained in a namespace unique to the plugin instance. This means that allocations of the same relative path by different plugin instances will not collide. Apart from that, you can not make any other assumptions about the absolute and abstract file paths.

An abstract file path that has been read from the plugin state can be mapped back to an absolute file path with the deabstract_path method.

Source

pub fn deabstract_path( &mut self, path: &str, ) -> Result<ManagedPath<'a>, StateErr>

Map an abstract file path back to an absolute one.

After reading an abstract file path from the state, you have to map it back to an absolute file path in order to read the file. This is what this method does.

Auto Trait Implementations§

§

impl<'a> Freeze for PathManager<'a>

§

impl<'a> RefUnwindSafe for PathManager<'a>

§

impl<'a> !Send for PathManager<'a>

§

impl<'a> !Sync for PathManager<'a>

§

impl<'a> Unpin for PathManager<'a>

§

impl<'a> UnsafeUnpin for PathManager<'a>

§

impl<'a> !UnwindSafe for PathManager<'a>

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, 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.