Struct UiTreeFolder

Source
pub struct UiTreeFolder<T, F = ()> {
    pub value: F,
    pub children: BTreeMap<String, Box<UiTreeItem<T, F>>>,
}

Fields§

§value: F§children: BTreeMap<String, Box<UiTreeItem<T, F>>>

Implementations§

Source§

impl<T, F> UiTreeFolder<T, F>

Source

pub fn new(value: F) -> Self

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§

impl<T, F> UiTreeFolder<T, F>
where F: Default,

Source

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

Trait Implementations§

Source§

impl<T: Clone, F: Clone> Clone for UiTreeFolder<T, F>

Source§

fn clone(&self) -> UiTreeFolder<T, F>

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, F: Debug> Debug for UiTreeFolder<T, F>

Source§

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

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

impl<T: Default, F: Default> Default for UiTreeFolder<T, F>

Source§

fn default() -> UiTreeFolder<T, F>

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

impl<'de, T, F> Deserialize<'de> for UiTreeFolder<T, F>
where T: Deserialize<'de>, F: 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<T: PartialEq, F: PartialEq> PartialEq for UiTreeFolder<T, F>

Source§

fn eq(&self, other: &UiTreeFolder<T, F>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const 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<T, F> Serialize for UiTreeFolder<T, F>
where T: Serialize, F: 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<T: Eq, F: Eq> Eq for UiTreeFolder<T, F>

Source§

impl<T, F> StructuralPartialEq for UiTreeFolder<T, F>

Auto Trait Implementations§

§

impl<T, F> Freeze for UiTreeFolder<T, F>
where F: Freeze,

§

impl<T, F> RefUnwindSafe for UiTreeFolder<T, F>

§

impl<T, F> Send for UiTreeFolder<T, F>
where F: Send, T: Send,

§

impl<T, F> Sync for UiTreeFolder<T, F>
where F: Sync, T: Sync,

§

impl<T, F> Unpin for UiTreeFolder<T, F>
where F: Unpin,

§

impl<T, F> UnwindSafe for UiTreeFolder<T, F>

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