Struct File

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

Resource representing file system file

Implementations§

Source§

impl File

Source

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

Create new File pointing to absolute file system path

Source

pub fn path(&self) -> &Path

Path reference to file system file

Source

pub fn created(self) -> Self

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

Source

pub fn create(&self) -> File

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

Source

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

Creates (or truncates) the file and any missing directories on it’s path in write only mode.

Source

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

Creating a link to this file from another directory with this file’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 file from another directory with this file’s name or stops the build with informative error message.

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

Creating a link to this file from another directory with this file’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 file will also fail.

Source

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

Create a symbolic link at this file path to given target file to creating any needed directories in the process returning self or stops 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 file path to given target file to creating any needed directories in the process or stops 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 file path to given target file 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 file set force to true or linking to a different file will also fail.

Source

pub fn metadata(&self) -> Metadata

Opens file’s metadata using metadata_result or stops the build with informative error message.

Source

pub fn metadata_result(&self) -> Result<Metadata>

Opens file metadata

Source

pub fn open(&self) -> File

Opens the file using open_result or stops the build with informative error message

Source

pub fn open_result(&self) -> Result<File>

Opens the file in read only mode

Source

pub fn rewrite<P: AsRef<[u8]>>(&self, bytes: P)

Writes the entire content to the file using rewrite_result or stops the build with informative error message

Source

pub fn rewrite_result<P: AsRef<[u8]>>(&self, bytes: P) -> Result<()>

Writes the entire content to the file if it is different then the current one creating the file if needed.

Source

pub fn touched(self) -> Self

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

Source

pub fn touch(&self)

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

Source

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

Touches the file by updating it’s modification time or creating an empty one if it does not exists yet including any needed directories.

Trait Implementations§

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 Add<&File> for &File

Source§

type Output = Set<File>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl AsRef<File> for File

Source§

fn as_ref(&self) -> &File

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

impl AsRef<OsStr> for File

Source§

fn as_ref(&self) -> &OsStr

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

impl AsRef<Path> for File

Source§

fn as_ref(&self) -> &Path

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

impl Clone for File

Source§

fn clone(&self) -> File

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 File

Source§

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

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

impl Display for File

Source§

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

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

impl Hash for File

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 File

Source§

fn cmp(&self, other: &File) -> 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 File

Source§

fn eq(&self, other: &File) -> 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 File

Source§

fn partial_cmp(&self, other: &File) -> 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 File

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 File

Source§

impl StructuralPartialEq for File

Auto Trait Implementations§

§

impl Freeze for File

§

impl RefUnwindSafe for File

§

impl Send for File

§

impl Sync for File

§

impl Unpin for File

§

impl UnwindSafe for File

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.