Skip to main content

DocumentStats

Struct DocumentStats 

Source
pub struct DocumentStats {
Show 14 fields pub total_nodes: usize, pub max_depth: usize, pub string_count: usize, pub number_count: usize, pub boolean_count: usize, pub array_count: usize, pub mapping_count: usize, pub set_count: usize, pub anchor_count: usize, pub alias_count: usize, pub tagged_count: usize, pub total_string_bytes: usize, pub largest_array: usize, pub largest_mapping: usize,
}
Expand description

Document statistics for performance analysis Statistics about a YAML document structure

Fields§

§total_nodes: usize

Total number of nodes in the document

§max_depth: usize

Maximum nesting depth

§string_count: usize

Number of string nodes

§number_count: usize

Number of numeric nodes

§boolean_count: usize

Number of boolean nodes

§array_count: usize

Number of array/sequence nodes

§mapping_count: usize

Number of mapping nodes

§set_count: usize

Number of set nodes

§anchor_count: usize

Number of anchor nodes

§alias_count: usize

Number of alias nodes

§tagged_count: usize

Number of tagged nodes

§total_string_bytes: usize

Total string length (bytes)

§largest_array: usize

Largest array size

§largest_mapping: usize

Largest mapping size

Implementations§

Source§

impl DocumentStats

Source

pub fn new() -> Self

Create a new empty statistics object

Source

pub fn from_node(node: &Node) -> Self

Gather statistics from a Node tree

§Example
let doc = Node::Array(vec![
    Node::from(1),
    Node::from("text"),
    Node::Array(vec![Node::from(2)])
]);

let stats = DocumentStats::from_node(&doc);
assert_eq!(stats.total_nodes, 5);
assert_eq!(stats.max_depth, 2);
assert_eq!(stats.array_count, 2);
Source

pub fn estimated_memory_bytes(&self) -> usize

Calculate estimated memory usage in bytes

Source

pub fn summary(&self) -> String

Get a human-readable summary

Trait Implementations§

Source§

impl Clone for DocumentStats

Source§

fn clone(&self) -> DocumentStats

Returns a duplicate 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 Debug for DocumentStats

Source§

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

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

impl Default for DocumentStats

Source§

fn default() -> DocumentStats

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

Auto Trait Implementations§

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.