pub fn map_dag<F>(ipld: &Ipld, transform: &F) -> IpldExpand description
Transform all nodes in a DAG using a mapping function.
Applies the transformation function to each node in the IPLD structure, building a new transformed DAG.
§Arguments
ipld- The IPLD data to transformtransform- Function to transform each node
§Returns
The transformed IPLD structure
§Examples
use ipfrs_core::Ipld;
use ipfrs_core::dag::map_dag;
let ipld = Ipld::Integer(42);
// Double all integers
let transformed = map_dag(&ipld, &|node| {
match node {
Ipld::Integer(n) => Ipld::Integer(n * 2),
other => other.clone(),
}
});
assert_eq!(transformed, Ipld::Integer(84));