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 entries_by_directory(
    &self
) -> BTreeMap<Option<&Path>, BTreeMap<&OsStr, &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]

impl Debug for FileManifest[src]

impl Default for FileManifest[src]

impl PartialEq<FileManifest> for FileManifest[src]

impl StructuralPartialEq for FileManifest[src]

Auto Trait Implementations

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, 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.