pub struct DagStats {
pub unique_cids: usize,
pub total_links: usize,
pub max_depth: usize,
pub leaf_count: usize,
pub intermediate_count: usize,
}Expand description
Statistics about a DAG structure
Fields§
§unique_cids: usizeTotal number of unique CIDs in the DAG
total_links: usizeTotal number of links (including duplicates)
max_depth: usizeMaximum depth of the DAG
leaf_count: usizeNumber of leaf nodes (nodes with no outgoing links)
intermediate_count: usizeNumber of intermediate nodes (nodes with outgoing links)
Implementations§
Source§impl DagStats
impl DagStats
Sourcepub fn from_ipld(ipld: &Ipld) -> Self
pub fn from_ipld(ipld: &Ipld) -> Self
Calculate statistics for an IPLD structure
Note: This only analyzes the structure of the IPLD data provided, it does not follow CID links to fetch additional blocks.
§Arguments
ipld- The IPLD data to analyze
§Returns
Statistics about the DAG structure
§Examples
use ipfrs_core::{Ipld, CidBuilder};
use ipfrs_core::dag::DagStats;
use std::collections::BTreeMap;
let cid = CidBuilder::new().build(b"data").unwrap();
let mut map = BTreeMap::new();
map.insert("link".to_string(), Ipld::link(cid));
let ipld = Ipld::Map(map);
let stats = DagStats::from_ipld(&ipld);
assert_eq!(stats.total_links, 1);
assert_eq!(stats.unique_cids, 1);Sourcepub fn deduplication_ratio(&self) -> f64
pub fn deduplication_ratio(&self) -> f64
Calculate the deduplication ratio
Returns the ratio of duplicate links to total links. A value of 0.0 means no duplication, 1.0 means all links are duplicates.
Trait Implementations§
impl Eq for DagStats
impl StructuralPartialEq for DagStats
Auto Trait Implementations§
impl Freeze for DagStats
impl RefUnwindSafe for DagStats
impl Send for DagStats
impl Sync for DagStats
impl Unpin for DagStats
impl UnwindSafe for DagStats
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more