Struct LeafTree

Source
pub struct LeafTree<T>(/* private fields */);

Implementations§

Source§

impl<T> LeafTree<T>

Source

pub fn new() -> Self

Source

pub fn add_folder( &mut self, path: &(impl AsRef<str> + ?Sized), ) -> Result<(), CosmicPathErr>

Adds a folder into the LeafTree. We removed the value argument in this wrapper, since all values for Folder data is ().

Source

pub fn iter(&self) -> impl Iterator<Item = (String, UiTreeItemRef<'_, T, ()>)>

This is a wrapper around a standard iterator. Note that it skips the root value, which is always ().

Source

pub fn files_paths(&self) -> impl Iterator<Item = (String, &T)>

This is a wrapper around a standard iterator. Note that it skips the root value, which is always ().

Source

pub fn clear(&mut self)

Awaken afresh, as if it were all just a bad dream

Methods from Deref<Target = UiTree<T, ()>>§

Source

pub fn iter_paths( &self, ) -> impl Iterator<Item = (String, UiTreeItemRef<'_, T, F>)>

Source

pub fn iter(&self) -> impl Iterator<Item = UiTreeItemRef<'_, T, F>>

Methods from Deref<Target = UiTreeFolder<T, F>>§

Source

pub fn clear(&mut self, value: F)

Clears this folder, and sets a new value for it.

Source

pub fn unique_path( &self, folder: &(impl AsRef<str> + ?Sized), base_file_name: &(impl AsRef<str> + ?Sized), ) -> String

Source

pub fn file(&self, path: &(impl AsRef<str> + ?Sized)) -> Option<&T>

Source

pub fn folder( &self, path: &(impl AsRef<str> + ?Sized), ) -> Option<&UiTreeFolder<T, F>>

Source

pub fn root(&self) -> UiTreeItemRef<'_, T, F>

Returns the root item. This is always a Folder.

Source

pub fn item( &self, path: &(impl AsRef<str> + ?Sized), ) -> Option<UiTreeItemRef<'_, T, F>>

Source

pub fn item_mut( &mut self, path: &(impl AsRef<str> + ?Sized), ) -> Option<UiTreeItemRefMut<'_, T, F>>

Source

pub fn file_mut(&mut self, path: &(impl AsRef<str> + ?Sized)) -> Option<&mut T>

Source

pub fn folder_mut( &mut self, path: &(impl AsRef<str> + ?Sized), ) -> Option<&mut UiTreeFolder<T, F>>

Source

pub fn item_exists(&self, path: &(impl AsRef<str> + ?Sized)) -> bool

Source

pub fn folder_exists(&self, path: &(impl AsRef<str> + ?Sized)) -> bool

Source

pub fn file_exists(&self, path: &(impl AsRef<str> + ?Sized)) -> bool

Source

pub fn add_item( &mut self, path: &(impl AsRef<str> + ?Sized), new_item: UiTreeItem<T, F>, ) -> Result<(), CosmicPathErr>

Source

pub fn add_file( &mut self, path: &(impl AsRef<str> + ?Sized), value: T, ) -> Result<(), CosmicPathErr>

Source

pub fn add_folder( &mut self, path: &(impl AsRef<str> + ?Sized), folder_value: F, ) -> Result<(), CosmicPathErr>

Source

pub fn remove_item( &mut self, path: &(impl AsRef<str> + ?Sized), ) -> Result<UiTreeItem<T, F>, CosmicPathErr>

Source

pub fn remove_file( &mut self, path: &(impl AsRef<str> + ?Sized), ) -> Result<T, CosmicPathErr>

Source

pub fn remove_folder( &mut self, path: &(impl AsRef<str> + ?Sized), ) -> Result<UiTreeFolder<T, F>, CosmicPathErr>

Source

pub fn move_item( &mut self, old_path: &(impl AsRef<str> + ?Sized), new_path: &(impl AsRef<str> + ?Sized), ) -> Result<(), CosmicPathErr>

Source

pub fn files(&self) -> impl Iterator<Item = &T>

Source

pub fn files_mut(&mut self) -> impl Iterator<Item = &mut T>

Source

pub fn files_paths( &self, base_path: String, ) -> impl Iterator<Item = (String, &T)>

Source

pub fn files_paths_mut( &mut self, base_path: String, ) -> impl Iterator<Item = (String, &mut T)>

Source

pub fn set_children( &mut self, children: BTreeMap<String, Box<UiTreeItem<T, F>>>, )

Directly sets the children

Source

pub fn iter(&self) -> impl Iterator<Item = UiTreeItemRef<'_, T, F>>

Source

pub fn iter_paths( &self, base: String, ) -> impl Iterator<Item = (String, UiTreeItemRef<'_, T, F>)>

Source

pub fn for_each_mut<R>( &mut self, empty_folders_pass: bool, filter: impl Fn(&str, &T) -> bool + Copy, on_item: impl FnMut(&str, &mut UiTreeItemRefMut<'_, T, F>) -> Option<R>, )

Performs an action

Source

pub fn for_each<R>( &self, empty_folders_pass: bool, filter: impl Fn(&str, &T) -> bool + Copy, on_item: impl FnMut(&str, &UiTreeItemRef<'_, T, F>) -> Option<R>, )

Performs an action

Source

pub fn add_folder_all( &mut self, path: &(impl AsRef<str> + ?Sized), ) -> Result<(), CosmicPathErr>

Trait Implementations§

Source§

impl<T: Clone> Clone for LeafTree<T>

Source§

fn clone(&self) -> LeafTree<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for LeafTree<T>

Source§

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

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

impl<T> Default for LeafTree<T>

Source§

fn default() -> Self

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

impl<T> Deref for LeafTree<T>

Source§

type Target = UiTree<T, ()>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T> DerefMut for LeafTree<T>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<'de, T> Deserialize<'de> for LeafTree<T>
where T: 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<Tree> FromIterator<(String, Tree)> for LeafTree<Tree>

Source§

fn from_iter<T: IntoIterator<Item = (String, Tree)>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl<T> Serialize for LeafTree<T>
where T: 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

Auto Trait Implementations§

§

impl<T> Freeze for LeafTree<T>

§

impl<T> RefUnwindSafe for LeafTree<T>
where T: RefUnwindSafe,

§

impl<T> Send for LeafTree<T>
where T: Send,

§

impl<T> Sync for LeafTree<T>
where T: Sync,

§

impl<T> Unpin for LeafTree<T>

§

impl<T> UnwindSafe for LeafTree<T>
where T: 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<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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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>,