MCPcopy Create free account
hub / github.com/argumentcomputer/ix / put

Method put

crates/kernel/src/shard.rs:315–327  ·  view source on GitHub ↗

Preorder serialization: `0u8, id(4)` for a leaf; `1u8, , ` for an internal node.

(&self, out: &mut Vec<u8>)

Source from the content-addressed store, hash-verified

313 pub fn prune(&self, keep: &impl Fn(u32) -> bool) -> Option<AggNode> {
314 match self {
315 AggNode::Leaf(id) => keep(*id).then_some(AggNode::Leaf(*id)),
316 AggNode::Internal(l, r) => match (l.prune(keep), r.prune(keep)) {
317 (Some(a), Some(b)) => Some(AggNode::Internal(Box::new(a), Box::new(b))),
318 (Some(a), None) | (None, Some(a)) => Some(a),
319 (None, None) => None,
320 },
321 }
322 }
323
324 /// Preorder serialization: `0u8, id(4)` for a leaf; `1u8, <left>, <right>` for
325 /// an internal node.
326 fn put(&self, out: &mut Vec<u8>) {
327 match self {
328 AggNode::Leaf(id) => {
329 out.push(0);
330 out.extend_from_slice(&id.to_le_bytes());

Callers 2

to_bytesMethod · 0.45
build_sub_envFunction · 0.45

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected