pub struct MergeableFileSystemTree<Path, FileContent>(/* private fields */)
where
Path: Ord;
Expand description
Representation of a filesystem which contains only files and directories.
The serialization of FileContent
(content of file) and BTreeMap<Path, Self>
(children of directory) must not share the same type. That is, FileContent
must
be serialized to things other than a dictionary.
Generic parameters:
Path
: Reference to a file in the filesystem.FileContent
: Content of a file.
Difference from FileSystemTree
:
FileSystemTree::build
cannot write over an existing directory.
On the other hand, MergeableFileSystemTree::build
either merges
the two directories if there’s no conflict.
Methods from Deref<Target = FileSystemTree<Path, FileContent>>§
Sourcepub fn file_content(&self) -> Option<&FileContent>
pub fn file_content(&self) -> Option<&FileContent>
Get immutable reference to the file content.
Sourcepub fn dir_content(&self) -> Option<&BTreeMap<Path, Self>>
pub fn dir_content(&self) -> Option<&BTreeMap<Path, Self>>
Get immutable reference to the directory content.
Sourcepub fn path<'a>(
&'a self,
path: &'a mut impl Iterator<Item = &'a Path>,
) -> Option<&'a Self>
pub fn path<'a>( &'a self, path: &'a mut impl Iterator<Item = &'a Path>, ) -> Option<&'a Self>
Get immutable reference to a descendant of any level.
Sourcepub fn file_content_mut(&mut self) -> Option<&mut FileContent>
pub fn file_content_mut(&mut self) -> Option<&mut FileContent>
Get mutable reference to the file content.
Sourcepub fn dir_content_mut(&mut self) -> Option<&mut BTreeMap<Path, Self>>
pub fn dir_content_mut(&mut self) -> Option<&mut BTreeMap<Path, Self>>
Get mutable reference to the directory content.
Trait Implementations§
Source§impl<Path, FileContent> AsMut<FileSystemTree<Path, FileContent>> for MergeableFileSystemTree<Path, FileContent>where
Path: Ord,
impl<Path, FileContent> AsMut<FileSystemTree<Path, FileContent>> for MergeableFileSystemTree<Path, FileContent>where
Path: Ord,
Source§fn as_mut(&mut self) -> &mut FileSystemTree<Path, FileContent>
fn as_mut(&mut self) -> &mut FileSystemTree<Path, FileContent>
Converts this type into a mutable reference of the (usually inferred) input type.
Source§impl<Path, FileContent> AsRef<FileSystemTree<Path, FileContent>> for MergeableFileSystemTree<Path, FileContent>where
Path: Ord,
impl<Path, FileContent> AsRef<FileSystemTree<Path, FileContent>> for MergeableFileSystemTree<Path, FileContent>where
Path: Ord,
Source§fn as_ref(&self) -> &FileSystemTree<Path, FileContent>
fn as_ref(&self) -> &FileSystemTree<Path, FileContent>
Converts this type into a shared reference of the (usually inferred) input type.
Source§impl<Name, FileContent> Build<Name, Error> for MergeableFileSystemTree<Name, FileContent>
impl<Name, FileContent> Build<Name, Error> for MergeableFileSystemTree<Name, FileContent>
Source§type BorrowedPath = Path
type BorrowedPath = Path
Build target.
Source§fn join(prefix: &Self::BorrowedPath, name: &Name) -> Self::OwnedPath
fn join(prefix: &Self::BorrowedPath, name: &Name) -> Self::OwnedPath
Add prefix to the root of the tree.
Source§fn write_file(
path: &Self::BorrowedPath,
content: &Self::FileContent,
) -> Result<(), Error>
fn write_file( path: &Self::BorrowedPath, content: &Self::FileContent, ) -> Result<(), Error>
Write content to a file.
Source§fn create_dir(path: &Self::BorrowedPath) -> Result<(), Error>
fn create_dir(path: &Self::BorrowedPath) -> Result<(), Error>
Create a directory at root.
Source§fn build<Path>(
self,
path: Path,
) -> Result<(), BuildError<Self::OwnedPath, Error>>where
Path: AsRef<Self::BorrowedPath>,
fn build<Path>(
self,
path: Path,
) -> Result<(), BuildError<Self::OwnedPath, Error>>where
Path: AsRef<Self::BorrowedPath>,
Build the tree into the filesystem.
Source§impl<Path, FileContent: Clone> Clone for MergeableFileSystemTree<Path, FileContent>
impl<Path, FileContent: Clone> Clone for MergeableFileSystemTree<Path, FileContent>
Source§fn clone(&self) -> MergeableFileSystemTree<Path, FileContent>
fn clone(&self) -> MergeableFileSystemTree<Path, FileContent>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<Path, FileContent: Debug> Debug for MergeableFileSystemTree<Path, FileContent>
impl<Path, FileContent: Debug> Debug for MergeableFileSystemTree<Path, FileContent>
Source§impl<Path, FileContent> Deref for MergeableFileSystemTree<Path, FileContent>where
Path: Ord,
impl<Path, FileContent> Deref for MergeableFileSystemTree<Path, FileContent>where
Path: Ord,
Source§impl<Path, FileContent> DerefMut for MergeableFileSystemTree<Path, FileContent>where
Path: Ord,
impl<Path, FileContent> DerefMut for MergeableFileSystemTree<Path, FileContent>where
Path: Ord,
Source§impl<'de, Path, FileContent> Deserialize<'de> for MergeableFileSystemTree<Path, FileContent>
impl<'de, Path, FileContent> Deserialize<'de> for MergeableFileSystemTree<Path, FileContent>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<Path, FileContent> From<FileSystemTree<Path, FileContent>> for MergeableFileSystemTree<Path, FileContent>where
Path: Ord,
impl<Path, FileContent> From<FileSystemTree<Path, FileContent>> for MergeableFileSystemTree<Path, FileContent>where
Path: Ord,
Source§fn from(value: FileSystemTree<Path, FileContent>) -> Self
fn from(value: FileSystemTree<Path, FileContent>) -> Self
Converts to this type from the input type.
Source§impl<Path, FileContent> From<MergeableFileSystemTree<Path, FileContent>> for FileSystemTree<Path, FileContent>where
Path: Ord,
impl<Path, FileContent> From<MergeableFileSystemTree<Path, FileContent>> for FileSystemTree<Path, FileContent>where
Path: Ord,
Source§fn from(value: MergeableFileSystemTree<Path, FileContent>) -> Self
fn from(value: MergeableFileSystemTree<Path, FileContent>) -> Self
Converts to this type from the input type.
Source§impl<Path, FileContent> Node for MergeableFileSystemTree<Path, FileContent>where
Path: Ord,
impl<Path, FileContent> Node for MergeableFileSystemTree<Path, FileContent>where
Path: Ord,
Source§type FileContent = FileContent
type FileContent = FileContent
Content of the node if it is a file.
Source§type DirectoryContent = BTreeMap<Path, MergeableFileSystemTree<Path, FileContent>>
type DirectoryContent = BTreeMap<Path, MergeableFileSystemTree<Path, FileContent>>
Content of the node if it is a directory.
Source§fn read(self) -> NodeContent<FileContent, Self::DirectoryContent>
fn read(self) -> NodeContent<FileContent, Self::DirectoryContent>
Read the content of the node.
Source§impl<Path, FileContent: PartialEq> PartialEq for MergeableFileSystemTree<Path, FileContent>
impl<Path, FileContent: PartialEq> PartialEq for MergeableFileSystemTree<Path, FileContent>
Source§fn eq(&self, other: &MergeableFileSystemTree<Path, FileContent>) -> bool
fn eq(&self, other: &MergeableFileSystemTree<Path, FileContent>) -> bool
Tests for
self
and other
values to be equal, and is used by ==
.Source§impl<Path, FileContent> Serialize for MergeableFileSystemTree<Path, FileContent>
impl<Path, FileContent> Serialize for MergeableFileSystemTree<Path, FileContent>
impl<Path, FileContent: Eq> Eq for MergeableFileSystemTree<Path, FileContent>
impl<Path, FileContent> StructuralPartialEq for MergeableFileSystemTree<Path, FileContent>where
Path: Ord,
Auto Trait Implementations§
impl<Path, FileContent> Freeze for MergeableFileSystemTree<Path, FileContent>where
FileContent: Freeze,
impl<Path, FileContent> RefUnwindSafe for MergeableFileSystemTree<Path, FileContent>where
FileContent: RefUnwindSafe,
Path: RefUnwindSafe,
impl<Path, FileContent> Send for MergeableFileSystemTree<Path, FileContent>
impl<Path, FileContent> Sync for MergeableFileSystemTree<Path, FileContent>
impl<Path, FileContent> Unpin for MergeableFileSystemTree<Path, FileContent>where
FileContent: Unpin,
impl<Path, FileContent> UnwindSafe for MergeableFileSystemTree<Path, FileContent>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.Source§impl<X> Pipe for X
impl<X> Pipe for X
Source§fn pipe_ref<'a, Return, Function>(&'a self, f: Function) -> Returnwhere
Function: FnOnce(&'a Self) -> Return,
fn pipe_ref<'a, Return, Function>(&'a self, f: Function) -> Returnwhere
Function: FnOnce(&'a Self) -> Return,
Source§fn pipe_mut<'a, Return, Function>(&'a mut self, f: Function) -> Returnwhere
Function: FnOnce(&'a mut Self) -> Return,
fn pipe_mut<'a, Return, Function>(&'a mut self, f: Function) -> Returnwhere
Function: FnOnce(&'a mut Self) -> Return,
Source§fn pipe_as_ref<'a, Param, Return, Function>(&'a self, f: Function) -> Return
fn pipe_as_ref<'a, Param, Return, Function>(&'a self, f: Function) -> Return
Apply
f
to &self
where f
takes a single parameter of type Param
and Self
implements trait AsRef<Param>
. Read moreSource§fn pipe_as_mut<'a, Param, Return, Function>(&'a mut self, f: Function) -> Return
fn pipe_as_mut<'a, Param, Return, Function>(&'a mut self, f: Function) -> Return
Apply
f
to &mut self
where f
takes a single parameter of type Param
and Self
implements trait AsMut<Param>
. Read moreSource§fn pipe_deref<'a, Param, Return, Function>(&'a self, f: Function) -> Return
fn pipe_deref<'a, Param, Return, Function>(&'a self, f: Function) -> Return
Apply
f
to &self
where f
takes a single parameter of type Param
and Self
implements trait Deref<Target = Param>
. Read moreSource§fn pipe_deref_mut<'a, Param, Return, Function>(
&'a mut self,
f: Function,
) -> Returnwhere
Self: DerefMut<Target = Param>,
Param: 'a + ?Sized,
Function: FnOnce(&'a mut Param) -> Return,
fn pipe_deref_mut<'a, Param, Return, Function>(
&'a mut self,
f: Function,
) -> Returnwhere
Self: DerefMut<Target = Param>,
Param: 'a + ?Sized,
Function: FnOnce(&'a mut Param) -> Return,
Apply
f
to &mut self
where f
takes a single parameter of type Param
and Self
implements trait [DerefMut<Target = Param>
]. Read moreSource§fn pipe_borrow<'a, Param, Return, Function>(&'a self, f: Function) -> Return
fn pipe_borrow<'a, Param, Return, Function>(&'a self, f: Function) -> Return
Apply
f
to &self
where f
takes a single parameter of type Param
and Self
implements trait Borrow<Param>
. Read moreSource§fn pipe_borrow_mut<'a, Param, Return, Function>(
&'a mut self,
f: Function,
) -> Return
fn pipe_borrow_mut<'a, Param, Return, Function>( &'a mut self, f: Function, ) -> Return
Apply
f
to &mut self
where f
takes a single parameter of type Param
and Self
implements trait BorrowMut<Param>
. Read more