Struct Reflection

Source
pub struct Reflection<Name, Size: Size> {
    pub name: Name,
    pub size: Size,
    pub children: Vec<Self>,
}
Expand description

Intermediate format used for construction and inspection of DataTree’s internal content.

Unlike Tree where the fields are all private, the fields of TreeReflection are all public to allow construction in tests.

Conversion between DataTree and Reflection:

  • Any DataTree can be safely transmuted to a valid Reflection.
  • Any Reflection can be safely transmuted to a potentially invalid DataTree.
  • To safely convert a DataTree into a Reflection without the unsafe keyword, use DataTree::into_reflection (it would be slower than using transmute).
  • To safely convert a Reflection into a valid DataTree, use par_try_into_tree.

Serialization and deserialization: (feature: json) Reflection implements Serialize and Deserialize traits, this allows functions in serde_json to convert a Reflection into/from JSON.

Fields§

§name: Name

Name of the tree.

§size: Size

Disk usage of a file or total disk usage of a folder.

§children: Vec<Self>

Data of children filesystem subtrees.

Implementations§

Source§

impl<Name, Size> Reflection<Name, Size>
where Name: Send, Size: Size + Send,

Source

pub fn par_try_into_tree( self, ) -> Result<DataTree<Name, Size>, ConversionError<Name, Size>>

Attempting to convert a Reflection into a valid DataTree.

Source

pub fn par_try_map<TargetName, TargetSize, Error, Transform>( self, transform: Transform, ) -> Result<Reflection<TargetName, TargetSize>, Error>
where TargetName: Send, TargetSize: Size + Send + Sync, Error: Send, Transform: Fn(Name, Size) -> Result<(TargetName, TargetSize), Error> + Copy + Sync,

Attempt to transform names and sizes.

Source

pub fn par_convert_names_to_utf8(self) -> Result<Reflection<String, Size>, Name>
where Name: AsRef<OsStr>, Size: Sync,

Attempt to convert all names from OsString to String.

Trait Implementations§

Source§

impl<Name: Clone, Size: Clone + Size> Clone for Reflection<Name, Size>

Source§

fn clone(&self) -> Reflection<Name, Size>

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<Name: Debug, Size: Debug + Size> Debug for Reflection<Name, Size>

Source§

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

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

impl<'de, Name, Size> Deserialize<'de> for Reflection<Name, Size>
where Name: Deserialize<'de>, Size: Deserialize<'de> + Size,

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<Name, Size: Size> From<DataTree<Name, Size>> for Reflection<Name, Size>

Source§

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

Converts to this type from the input type.
Source§

impl From<Reflection<String, Blocks>> for UnitAndTree

Source§

fn from(value: Reflection<String, Blocks>) -> Self

Converts to this type from the input type.
Source§

impl From<Reflection<String, Bytes>> for UnitAndTree

Source§

fn from(value: Reflection<String, Bytes>) -> Self

Converts to this type from the input type.
Source§

impl<Name: PartialEq, Size: PartialEq + Size> PartialEq for Reflection<Name, Size>

Source§

fn eq(&self, other: &Reflection<Name, Size>) -> 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<Name, Size> Serialize for Reflection<Name, Size>
where Name: Serialize, Size: Serialize + Size,

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 TryFrom<UnitAndTree> for Reflection<String, Blocks>

Source§

type Error = TryIntoError<UnitAndTree>

The type returned in the event of a conversion error.
Source§

fn try_from(value: UnitAndTree) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<UnitAndTree> for Reflection<String, Bytes>

Source§

type Error = TryIntoError<UnitAndTree>

The type returned in the event of a conversion error.
Source§

fn try_from(value: UnitAndTree) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<Name: Eq, Size: Eq + Size> Eq for Reflection<Name, Size>

Source§

impl<Name, Size: Size> StructuralPartialEq for Reflection<Name, Size>

Auto Trait Implementations§

§

impl<Name, Size> Freeze for Reflection<Name, Size>
where Name: Freeze, Size: Freeze,

§

impl<Name, Size> RefUnwindSafe for Reflection<Name, Size>
where Name: RefUnwindSafe, Size: RefUnwindSafe,

§

impl<Name, Size> Send for Reflection<Name, Size>
where Name: Send, Size: Send,

§

impl<Name, Size> Sync for Reflection<Name, Size>
where Name: Sync, Size: Sync,

§

impl<Name, Size> Unpin for Reflection<Name, Size>
where Name: Unpin, Size: Unpin,

§

impl<Name, Size> UnwindSafe for Reflection<Name, Size>
where Name: UnwindSafe, Size: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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>,