Struct tugger_file_manifest::FileManifest[][src]

pub struct FileManifest { /* fields omitted */ }

Represents a collection of files.

Files are keyed by their path. The file content is abstract and can be backed by multiple sources.

Implementations

impl FileManifest[src]

pub fn is_empty(&self) -> bool[src]

Whether the instance has any files entries.

pub fn add_path(
    &mut self,
    path: impl AsRef<Path>,
    strip_prefix: impl AsRef<Path>
) -> Result<(), FileManifestError>
[src]

Add a file on the filesystem to the manifest.

The filesystem path must have a prefix specified which will be stripped from the manifest path. This prefix must appear in the passed path.

The stored file data is a reference to the file path. So that file must outlive this manifest instance.

pub fn add_path_memory(
    &mut self,
    path: impl AsRef<Path>,
    strip_prefix: impl AsRef<Path>
) -> Result<(), FileManifestError>
[src]

Add a file on the filesystem to this manifest, reading file data into memory.

This is like add_path() except the file is read and its contents stored in memory. This ensures that the file can be materialized even if the source file is deleted.

pub fn add_file_entry(
    &mut self,
    path: impl AsRef<Path>,
    entry: impl Into<FileEntry>
) -> Result<(), FileManifestError>
[src]

Add a FileEntry to this manifest under the given path.

The path cannot contain relative paths and must not be absolute.

pub fn add_files(
    &mut self,
    files: impl Iterator<Item = File>
) -> Result<(), FileManifestError>
[src]

Add an iterable of File to this manifest.

pub fn add_manifest(&mut self, other: &Self) -> Result<(), FileManifestError>[src]

Merge the content of another manifest into this one.

All entries from the other manifest are overlayed into this manifest while preserving paths exactly. If this manifest already has an entry for a given path, it will be overwritten by an entry in the other manifest.

pub fn relative_directories(&self) -> Vec<PathBuf>[src]

Obtain all relative directories contained within files in this manifest.

The root directory is not represented in the return value.

pub fn resolve_directories(&self, relative_to: impl AsRef<Path>) -> Vec<PathBuf>[src]

Resolve all required directories relative to another directory.

The root directory itself is included.

pub fn has_path(&self, path: impl AsRef<Path>) -> bool[src]

Whether this manifest contains the specified file path.

pub fn get(&self, path: impl AsRef<Path>) -> Option<&FileEntry>[src]

Obtain the entry for a given path.

pub fn iter_entries(&self) -> Iter<'_, PathBuf, FileEntry>[src]

Obtain an iterator over paths and file entries in this manifest.

pub fn iter_files(&self) -> impl Iterator<Item = File> + '_[src]

Obtain an iterator of entries as File instances.

pub fn remove(&mut self, path: impl AsRef<Path>) -> Option<FileEntry>[src]

Remove an entry from this manifest.

pub fn entries_by_directory(
    &self
) -> BTreeMap<Option<&Path>, BTreeMap<&OsStr, (&Path, &FileEntry)>>
[src]

Obtain entries in this manifest grouped by directory.

The returned map has keys corresponding to the relative directory and values of files in that directory.

The root directory is modeled by the None key.

pub fn materialize_files(
    &self,
    dest: impl AsRef<Path>
) -> Result<Vec<PathBuf>, FileManifestError>
[src]

Write files in this manifest to the specified path.

Existing files will be replaced if they exist.

pub fn materialize_files_with_replace(
    &self,
    dest: impl AsRef<Path>
) -> Result<Vec<PathBuf>, FileManifestError>
[src]

Calls materialize_files() but removes the destination directory if it exists.

This ensures the content of the destination reflects exactly what’s defined in this manifest.

Trait Implementations

impl Clone for FileManifest[src]

fn clone(&self) -> FileManifest[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for FileManifest[src]

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

Formats the value using the given formatter. Read more

impl Default for FileManifest[src]

fn default() -> FileManifest[src]

Returns the “default value” for a type. Read more

impl PartialEq<FileManifest> for FileManifest[src]

fn eq(&self, other: &FileManifest) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &FileManifest) -> bool[src]

This method tests for !=.

impl StructuralPartialEq for FileManifest[src]

Auto Trait Implementations

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

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.

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

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.