[][src]Struct superfusion::index::Index

pub struct Index { /* fields omitted */ }

A relative path to the project that also carry information about where the path is from.

Implementations

impl Index[src]

pub fn new(pid: Pid, path: impl Into<PathBuf>) -> Self[src]

pub fn path(&self) -> &Path[src]

pub fn pid(&self) -> &Pid[src]

pub fn is_similar(&self, other: &Self) -> bool[src]

Compare only the path component of this struct

let foo = Index::new(Pid::new(0), "./path/to/index");
let bar = Index::new(Pid::new(1), "./path/to/index");
assert!(foo.is_similar(&bar));

let baz = Index::new(Pid::new(1), "./not/a/path/to/index");
assert!(!foo.is_similar(&baz));

pub fn rename<F>(&self, format: F) -> Result<Self, Error> where
    F: Fn(&Pid, &str) -> String
[src]

This method will attempt to create a file name that is unique across the entire workspace. It's usually called when workspace found a conflicting file.

Note

  1. format is a 'formatter function', this function must return a unique formatted string base on its Pid and filename.
  2. Changing file extension is not permitted.

Error

This function can fail in the following errors:

  • Logical parent does not exists. (Path like ./ does not have logical parent)
  • Unable to get file stem of this path. (Check Path::file_stem())

pub fn prefix(&self, root: &Path) -> PathBuf[src]

Transforming the Index into full path again by prefixing the relative path with the given root

pub fn with_pid(&self, pid: Pid) -> Self[src]

Return the same Index with different Pid

Trait Implementations

impl Clone for Index[src]

impl Debug for Index[src]

impl Display for Index[src]

impl Eq for Index[src]

impl<'a> FromIterator<&'a Index> for IndexList<'a>[src]

impl Hash for Index[src]

impl PartialEq<Index> for Index[src]

impl StructuralEq for Index[src]

impl StructuralPartialEq for Index[src]

Auto Trait Implementations

impl RefUnwindSafe for Index

impl Send for Index

impl Sync for Index

impl Unpin for Index

impl UnwindSafe for Index

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.