pub struct DataTree<Name, Data: Size> { /* private fields */ }
Expand description

Disk usage data of a filesystem tree.

Construction: There are 3 main ways to create a DataTree:

Visualization: Use the Visualizer struct to create an ASCII chart that visualizes DataTree.

Serialization and deserialization: (feature: json) DataTree does not implement Serialize and Deserialize traits directly, instead, it can be converted into/from a Reflection which implements these traits.

Implementations§

source§

impl<Name, Data: Size> DataTree<Name, Data>

source

pub fn into_reflection(self) -> Reflection<Name, Data>

Create reflection.

source§

impl<Name, Data: Size> DataTree<Name, Data>

source

pub fn dir(name: Name, inode_size: Data, children: Vec<Self>) -> Self

Create a tree representation of a directory.

source

pub fn file(name: Name, data: Data) -> Self

Create a tree representation of a file.

source

pub fn fixed_size_dir_constructor( inode_size: Data ) -> impl Fn(Name, Vec<Self>) -> Self
where Data: Copy,

Create a directory constructor of fixed inode size.

source§

impl<Name, Data: Size> DataTree<Name, Data>

source

pub fn name(&self) -> &Name

Extract name

source

pub fn name_mut(&mut self) -> &mut Name

Get mutable reference to name.

source

pub fn data(&self) -> Data

Extract total disk usage

source

pub fn children(&self) -> &Vec<Self>

Extract children

source§

impl<Name, Data> DataTree<Name, Data>
where Self: Send, Data: Size,

source

pub fn par_retain(&mut self, predicate: impl Fn(&Self) -> bool + Copy + Sync)

Recursively cull all descendants that do not satisfy given predicate, in parallel.

source

pub fn into_par_retained( self, predicate: impl Fn(&Self) -> bool + Copy + Sync ) -> Self

Process the tree via par_retain method.

source

pub fn par_cull_insignificant_data(&mut self, min_ratio: f32)
where Data: Into<u64>,

Recursively cull all descendants whose data are too small relative to root.

source§

impl<Name, Data> DataTree<Name, Data>
where Self: Send, Data: Size,

source

pub fn par_sort_by( &mut self, compare: impl Fn(&Self, &Self) -> Ordering + Copy + Sync )

Sort all descendants recursively, in parallel.

source

pub fn into_par_sorted( self, compare: impl Fn(&Self, &Self) -> Ordering + Copy + Sync ) -> Self

Process the tree via par_sort_by method.

Trait Implementations§

source§

impl<Name: Debug, Data: Debug + Size> Debug for DataTree<Name, Data>

source§

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

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

impl<Name, Data: Size> From<DataTree<Name, Data>> for Reflection<Name, Data>

source§

fn from(source: DataTree<Name, Data>) -> Self

Converts to this type from the input type.
source§

impl<Data, GetData, Report> From<FsTreeBuilder<Data, GetData, Report>> for DataTree<OsStringDisplay, Data>
where Data: Size + Send + Sync, GetData: Fn(&Metadata) -> Data + Sync, Report: Reporter<Data> + Sync,

source§

fn from(builder: FsTreeBuilder<Data, GetData, Report>) -> Self

Create a DataTree from an FsTreeBuilder.

source§

impl<Path, Name, Data, GetInfo, JoinPath> From<TreeBuilder<Path, Name, Data, GetInfo, JoinPath>> for DataTree<Name, Data>
where Path: Send + Sync, Name: Send + Sync, Data: Size + Send, GetInfo: Fn(&Path) -> Info<Name, Data> + Copy + Send + Sync, JoinPath: Fn(&Path, &Name) -> Path + Copy + Send + Sync,

source§

fn from(builder: TreeBuilder<Path, Name, Data, GetInfo, JoinPath>) -> Self

Create a DataTree from a TreeBuilder.

source§

impl<Name: PartialEq, Data: PartialEq + Size> PartialEq for DataTree<Name, Data>

source§

fn eq(&self, other: &DataTree<Name, Data>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<Name: Eq, Data: Eq + Size> Eq for DataTree<Name, Data>

source§

impl<Name, Data: Size> StructuralPartialEq for DataTree<Name, Data>

Auto Trait Implementations§

§

impl<Name, Data> RefUnwindSafe for DataTree<Name, Data>
where Data: RefUnwindSafe, Name: RefUnwindSafe,

§

impl<Name, Data> Send for DataTree<Name, Data>
where Data: Send, Name: Send,

§

impl<Name, Data> Sync for DataTree<Name, Data>
where Data: Sync, Name: Sync,

§

impl<Name, Data> Unpin for DataTree<Name, Data>
where Data: Unpin, Name: Unpin,

§

impl<Name, Data> UnwindSafe for DataTree<Name, Data>
where Data: UnwindSafe, Name: UnwindSafe,

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

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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.