Enum FileSystemTree

Source
pub enum FileSystemTree<Path, FileContent>
where Path: Ord,
{ File(FileContent), Directory(BTreeMap<Path, Self>), }
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.

Note: FileSystemTree::build cannot write over an existing directory. Use MergeableFileSystemTree instead if you desire such behavior.

Generic parameters:

  • Path: Reference to a file in the filesystem.
  • FileContent: Content of a file.

Variants§

§

File(FileContent)

Represents a file with its content. Its YAML representation must not have the same type as FileSystemTree::Directory’s.

§

Directory(BTreeMap<Path, Self>)

Represents a directory with its children. It is a set of name-to-subtree mappings. Its YAML representation must not have the same type as FileSystemTree::File’s.

Implementations§

Source§

impl<Path, FileContent> FileSystemTree<Path, FileContent>
where Path: Ord,

Source

pub fn file_content(&self) -> Option<&FileContent>

Get immutable reference to the file content.

Source

pub fn dir_content(&self) -> Option<&BTreeMap<Path, Self>>

Get immutable reference to the directory content.

Source

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.

Source

pub fn file_content_mut(&mut self) -> Option<&mut FileContent>

Get mutable reference to the file content.

Source

pub fn dir_content_mut(&mut self) -> Option<&mut BTreeMap<Path, Self>>

Get mutable reference to the directory content.

Source

pub fn path_mut<'a>( &'a mut self, path: &'a mut impl Iterator<Item = &'a Path>, ) -> Option<&'a mut Self>

Get mutable reference to a descendant of any level.

Trait Implementations§

Source§

impl<Path, FileContent> AsMut<FileSystemTree<Path, FileContent>> for MergeableFileSystemTree<Path, FileContent>
where Path: Ord,

Source§

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,

Source§

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 FileSystemTree<Name, FileContent>
where Name: AsRef<Path> + Ord, FileContent: AsRef<[u8]>,

Source§

type BorrowedPath = Path

Build target.
Source§

type OwnedPath = PathBuf

Locations of the items in the filesystem.
Source§

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>

Write content to a file.
Source§

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

Build the tree into the filesystem.
Source§

impl<Path, FileContent: Clone> Clone for FileSystemTree<Path, FileContent>
where Path: Ord + Clone,

Source§

fn clone(&self) -> FileSystemTree<Path, FileContent>

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<Path, FileContent: Debug> Debug for FileSystemTree<Path, FileContent>
where Path: Ord + Debug,

Source§

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

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

impl<'de, Path, FileContent> Deserialize<'de> for FileSystemTree<Path, FileContent>
where Path: Ord + Deserialize<'de>, FileContent: Deserialize<'de>,

Source§

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,

Source§

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,

Source§

fn from(value: MergeableFileSystemTree<Path, FileContent>) -> Self

Converts to this type from the input type.
Source§

impl<Path, FileContent> Node for FileSystemTree<Path, FileContent>
where Path: Ord,

Source§

type FileContent = FileContent

Content of the node if it is a file.
Source§

type DirectoryContent = BTreeMap<Path, FileSystemTree<Path, FileContent>>

Content of the node if it is a directory.
Source§

fn read(self) -> NodeContent<FileContent, Self::DirectoryContent>

Read the content of the node.
Source§

impl<Path, FileContent: PartialEq> PartialEq for FileSystemTree<Path, FileContent>
where Path: Ord + PartialEq,

Source§

fn eq(&self, other: &FileSystemTree<Path, FileContent>) -> 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<Path, FileContent> Serialize for FileSystemTree<Path, FileContent>
where Path: Ord + Serialize, FileContent: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<Path, FileContent: Eq> Eq for FileSystemTree<Path, FileContent>
where Path: Ord + Eq,

Source§

impl<Path, FileContent> StructuralPartialEq for FileSystemTree<Path, FileContent>
where Path: Ord,

Auto Trait Implementations§

§

impl<Path, FileContent> Freeze for FileSystemTree<Path, FileContent>
where FileContent: Freeze,

§

impl<Path, FileContent> RefUnwindSafe for FileSystemTree<Path, FileContent>
where FileContent: RefUnwindSafe, Path: RefUnwindSafe,

§

impl<Path, FileContent> Send for FileSystemTree<Path, FileContent>
where FileContent: Send, Path: Send,

§

impl<Path, FileContent> Sync for FileSystemTree<Path, FileContent>
where FileContent: Sync, Path: Sync,

§

impl<Path, FileContent> Unpin for FileSystemTree<Path, FileContent>
where FileContent: Unpin,

§

impl<Path, FileContent> UnwindSafe for FileSystemTree<Path, FileContent>
where FileContent: UnwindSafe + RefUnwindSafe, Path: RefUnwindSafe,

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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<X> Pipe for X

Source§

fn pipe<Return, Function>(self, f: Function) -> Return
where Self: Sized, Function: FnOnce(Self) -> Return,

Apply f to self. Read more
Source§

fn pipe_ref<'a, Return, Function>(&'a self, f: Function) -> Return
where Function: FnOnce(&'a Self) -> Return,

Apply f to &self. Read more
Source§

fn pipe_mut<'a, Return, Function>(&'a mut self, f: Function) -> Return
where Function: FnOnce(&'a mut Self) -> Return,

Apply f to &mut self. Read more
Source§

fn pipe_as_ref<'a, Param, Return, Function>(&'a self, f: Function) -> Return
where Self: AsRef<Param>, Param: 'a + ?Sized, Function: FnOnce(&'a Param) -> Return,

Apply f to &self where f takes a single parameter of type Param and Self implements trait AsRef<Param>. Read more
Source§

fn pipe_as_mut<'a, Param, Return, Function>(&'a mut self, f: Function) -> Return
where Self: AsMut<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 AsMut<Param>. Read more
Source§

fn pipe_deref<'a, Param, Return, Function>(&'a self, f: Function) -> Return
where Self: Deref<Target = Param>, Param: 'a + ?Sized, Function: FnOnce(&'a Param) -> Return,

Apply f to &self where f takes a single parameter of type Param and Self implements trait Deref<Target = Param>. Read more
Source§

fn pipe_deref_mut<'a, Param, Return, Function>( &'a mut self, f: Function, ) -> Return
where 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 more
Source§

fn pipe_borrow<'a, Param, Return, Function>(&'a self, f: Function) -> Return
where Self: Borrow<Param>, Param: 'a + ?Sized, Function: FnOnce(&'a Param) -> Return,

Apply f to &self where f takes a single parameter of type Param and Self implements trait Borrow<Param>. Read more
Source§

fn pipe_borrow_mut<'a, Param, Return, Function>( &'a mut self, f: Function, ) -> Return
where Self: BorrowMut<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 BorrowMut<Param>. Read more
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, 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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,