Struct Dir

Source
pub struct Dir { /* private fields */ }
Expand description

Resource representing file system directory

Implementations§

Source§

impl Dir

Source

pub fn new<P: AsRef<Path>>(path: P) -> Self

Create new Dir pointing to absolute file system path panicking if failed

Source

pub fn new_safe<P: AsRef<Path>>(path: P) -> Result<Self, Box<dyn Error>>

Create new Dir pointing to absolute file system path

Source

pub fn path(&self) -> &Path

Path reference to file system directory

Source

pub fn created(self) -> Self

Creates the directory using create and returns itself or stops the build with informative error message.

Source

pub fn create(&self)

Creates the directory using create_result or stops the build with informative error message.

Source

pub fn create_result(&self) -> Result<()>

Creates the directory and any missing parent directories on it’s path.

Source

pub fn content<G: AsRef<str>>(&self, glob: G) -> DirContent<Unit>

All directory content (files, directories and links) matching given glob file name pattern

Source

pub fn dirs<G: AsRef<str>>(&self, glob: G) -> DirContent<Dir>

All subdirectories and directory links matching given glob file name pattern

Source

pub fn files<G: AsRef<str>>(&self, glob: G) -> DirContent<File>

All files and file links matching given glob file name pattern

Source

pub fn dir<P: AsRef<Path>>(&self, path: P) -> Dir

Subdirectory at given relative path

Will stop the build with informative error message if path is not relative.

Source

pub fn dir_result<P: AsRef<Path>>( &self, path: P, ) -> Result<Self, Box<dyn Error>>

Subdirectory at given relative path

Source

pub fn file<P: AsRef<Path>>(&self, path: P) -> File

A file at given relative path

Will stop the build with informative error message if path is not relative.

Source

pub fn file_result<P: AsRef<Path>>( &self, path: P, ) -> Result<File, Box<dyn Error>>

A file at given relative path

Source

pub fn linked_from_inside(self, dir: &Dir) -> Self

Creating a link to this directory from another directory with this directory’s name returning self or stopping the build with informative error message.

If the directory already contains an entry with this name, linking fails.

Creating a link to this directory from another directory with this directory’s name or stopping the build with informative error message.

If the directory already contains an entry with this name, linking fails.

Creating a link to this directory from another directory with this directory’s name.

If the directory already contains a file or directory by this name, linking fails. To allow overwriting existing link with different target set force to true or linking to this directory will also fail.

Source

pub fn linked_to(self, to: &Dir) -> Self

Create a symbolic link at this directory path to given target directory to creating any needed directories in the process returning self or stopping the build with informative error message.

If a file or directory by that name already exists, linking will fail.

Create a symbolic link at this directory path to given target directory to creating any needed directories in the process or stopping the build with informative error message.

If a file or directory by that name already exists, linking will fail.

Create a symbolic link at this directory path to given target directory to creating any needed directories in the process.

If a file or directory by that name already exists, linking will fail. To allow overwriting existing link to a different directory set force to true or linking to a different directory will also fail.

Source

pub fn touched(self) -> Self

Touches the directory using touch and returns itself or stops the build with informative error message

Source

pub fn touch(&self)

Touches the directory using touch and returns itself or stops the build with informative error message.

Source

pub fn touch_result(&self) -> Result<()>

Touches the directory by updating it’s modification time or creating a new one if it does not exists yet including any needed directories.

Trait Implementations§

Source§

impl Add<&Dir> for &Dir

Source§

type Output = Set<Dir>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Dir) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<&Dir> for &File

Source§

type Output = Set<Unit>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Dir) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<&File> for &Dir

Source§

type Output = Set<Unit>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &File) -> Self::Output

Performs the + operation. Read more
Source§

impl AsRef<Dir> for Dir

Source§

fn as_ref(&self) -> &Dir

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<OsStr> for Dir

Source§

fn as_ref(&self) -> &OsStr

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Path> for Dir

Source§

fn as_ref(&self) -> &Path

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Dir

Source§

fn clone(&self) -> Dir

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Dir

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Dir

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Hash for Dir

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Dir

Source§

fn cmp(&self, other: &Dir) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Dir

Source§

fn eq(&self, other: &Dir) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Dir

Source§

fn partial_cmp(&self, other: &Dir) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Resource for Dir

Source§

fn timestamp(&self) -> Option<SystemTime>

Name of the resource used for logging and error reporting Return resource timestamp. Can be None for input resources that should be considered as changed in every build run or output resources that do not exists yet.
Source§

fn mk_from<F, R, S>(&self, description: &str, src: S, by: F)
where R: Resource, S: AsResource<R>, F: FnOnce(),

Build the resource form a given src resource as a side product of given function by respecting resource timestamps meaning that function by will only be ran if the output needs to be build. Read more
Source§

fn mk_from_result<E, F, R, S>( &self, description: &str, src: S, by: F, ) -> Result<(), E>
where R: Resource, S: AsRef<R>, F: FnOnce() -> Result<(), E>,

Same as mk_from() with error propagation
Source§

impl Eq for Dir

Source§

impl StructuralPartialEq for Dir

Auto Trait Implementations§

§

impl Freeze for Dir

§

impl RefUnwindSafe for Dir

§

impl Send for Dir

§

impl Sync for Dir

§

impl Unpin for Dir

§

impl UnwindSafe for Dir

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.