Struct tugger_file_manifest::FileManifest
source · [−]pub struct FileManifest { /* private fields */ }
Expand description
Represents a collection of files.
Files are keyed by their path. The file content is abstract and can be backed by multiple sources.
Implementations
sourceimpl FileManifest
impl FileManifest
sourcepub fn new_with_links() -> Self
pub fn new_with_links() -> Self
Create a new instance that allows the storage of links.
sourcepub fn add_path(
&mut self,
path: impl AsRef<Path>,
strip_prefix: impl AsRef<Path>
) -> Result<(), FileManifestError>
pub fn add_path(
&mut self,
path: impl AsRef<Path>,
strip_prefix: impl AsRef<Path>
) -> Result<(), FileManifestError>
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.
sourcepub fn add_path_memory(
&mut self,
path: impl AsRef<Path>,
strip_prefix: impl AsRef<Path>
) -> Result<(), FileManifestError>
pub fn add_path_memory(
&mut self,
path: impl AsRef<Path>,
strip_prefix: impl AsRef<Path>
) -> Result<(), FileManifestError>
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.
sourcepub fn add_file_entry(
&mut self,
path: impl AsRef<Path>,
entry: impl Into<FileEntry>
) -> Result<(), FileManifestError>
pub fn add_file_entry(
&mut self,
path: impl AsRef<Path>,
entry: impl Into<FileEntry>
) -> Result<(), FileManifestError>
Add a FileEntry
to this manifest under the given path.
The path cannot contain relative paths and must not be absolute.
sourcepub fn add_files(
&mut self,
files: impl Iterator<Item = File>
) -> Result<(), FileManifestError>
pub fn add_files(
&mut self,
files: impl Iterator<Item = File>
) -> Result<(), FileManifestError>
Add an iterable of File
to this manifest.
sourcepub fn add_symlink(
&mut self,
manifest_path: impl AsRef<Path>,
link_target: impl AsRef<Path>
) -> Result<(), FileManifestError>
pub fn add_symlink(
&mut self,
manifest_path: impl AsRef<Path>,
link_target: impl AsRef<Path>
) -> Result<(), FileManifestError>
Add a symlink to the manifest.
sourcepub fn add_manifest(&mut self, other: &Self) -> Result<(), FileManifestError>
pub fn add_manifest(&mut self, other: &Self) -> Result<(), FileManifestError>
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.
sourcepub fn relative_directories(&self) -> Vec<PathBuf>
pub fn relative_directories(&self) -> Vec<PathBuf>
Obtain all relative directories contained within files in this manifest.
The root directory is not represented in the return value.
sourcepub fn resolve_directories(&self, relative_to: impl AsRef<Path>) -> Vec<PathBuf>
pub fn resolve_directories(&self, relative_to: impl AsRef<Path>) -> Vec<PathBuf>
Resolve all required directories relative to another directory.
The root directory itself is included.
sourcepub fn has_path(&self, path: impl AsRef<Path>) -> bool
pub fn has_path(&self, path: impl AsRef<Path>) -> bool
Whether this manifest contains the specified file path.
sourcepub fn get(&self, path: impl AsRef<Path>) -> Option<&FileEntry>
pub fn get(&self, path: impl AsRef<Path>) -> Option<&FileEntry>
Obtain the entry for a given path.
sourcepub fn iter_entries(&self) -> Iter<'_, PathBuf, FileEntry>
pub fn iter_entries(&self) -> Iter<'_, PathBuf, FileEntry>
Obtain an iterator over paths and file entries in this manifest.
sourcepub fn iter_files(&self) -> impl Iterator<Item = File> + '_
pub fn iter_files(&self) -> impl Iterator<Item = File> + '_
Obtain an iterator of entries as File
instances.
sourcepub fn remove(&mut self, path: impl AsRef<Path>) -> Option<FileEntry>
pub fn remove(&mut self, path: impl AsRef<Path>) -> Option<FileEntry>
Remove an entry from this manifest.
sourcepub fn entries_by_directory(
&self
) -> BTreeMap<Option<&Path>, BTreeMap<&OsStr, (&Path, &FileEntry)>>
pub fn entries_by_directory(
&self
) -> BTreeMap<Option<&Path>, BTreeMap<&OsStr, (&Path, &FileEntry)>>
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.
sourcepub fn materialize_files(
&self,
dest: impl AsRef<Path>
) -> Result<Vec<PathBuf>, FileManifestError>
pub fn materialize_files(
&self,
dest: impl AsRef<Path>
) -> Result<Vec<PathBuf>, FileManifestError>
Write files in this manifest to the specified path.
Existing files will be replaced if they exist.
sourcepub fn materialize_files_with_replace(
&self,
dest: impl AsRef<Path>
) -> Result<Vec<PathBuf>, FileManifestError>
pub fn materialize_files_with_replace(
&self,
dest: impl AsRef<Path>
) -> Result<Vec<PathBuf>, FileManifestError>
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.
sourcepub fn ensure_in_memory(&mut self) -> Result<(), Error>
pub fn ensure_in_memory(&mut self) -> Result<(), Error>
Ensure the content of all entries is backed by memory.
Trait Implementations
sourceimpl Clone for FileManifest
impl Clone for FileManifest
sourcefn clone(&self) -> FileManifest
fn clone(&self) -> FileManifest
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for FileManifest
impl Debug for FileManifest
sourceimpl Default for FileManifest
impl Default for FileManifest
sourcefn default() -> FileManifest
fn default() -> FileManifest
Returns the “default value” for a type. Read more
sourceimpl PartialEq<FileManifest> for FileManifest
impl PartialEq<FileManifest> for FileManifest
sourcefn eq(&self, other: &FileManifest) -> bool
fn eq(&self, other: &FileManifest) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &FileManifest) -> bool
fn ne(&self, other: &FileManifest) -> bool
This method tests for !=
.
impl StructuralPartialEq for FileManifest
Auto Trait Implementations
impl RefUnwindSafe for FileManifest
impl Send for FileManifest
impl Sync for FileManifest
impl Unpin for FileManifest
impl UnwindSafe for FileManifest
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more