MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / decode_inode_attr_event

Function decode_inode_attr_event

atomic-core/src/pristine/attribute.rs:78–96  ·  view source on GitHub ↗
(
    bytes: &[u8; INODE_ATTR_EVENT_SIZE],
)

Source from the content-addressed store, hash-verified

76}
77
78pub fn decode_inode_attr_event(
79 bytes: &[u8; INODE_ATTR_EVENT_SIZE],
80) -> PristineResult<InodeAttrEvent> {
81 if bytes[0] != INODE_ATTR_EVENT_VERSION {
82 return Err(invalid_attr(format!(
83 "unsupported event version {}",
84 bytes[0]
85 )));
86 }
87 let name = InodeAttrName::from_byte(bytes[1])
88 .ok_or_else(|| invalid_attr(format!("unsupported attribute name {}", bytes[1])))?;
89 let introduced_by = NodeId::new(u64::from_le_bytes(bytes[2..10].try_into().unwrap()));
90 let len = usize::from(bytes[10]);
91 if len > 2 || bytes[11 + len..13].iter().any(|byte| *byte != 0) {
92 return Err(invalid_attr("non-canonical value padding"));
93 }
94 let value = InodeAttr::from_canonical(name, &bytes[11..11 + len]).map_err(invalid_attr)?;
95 InodeAttrEvent::new(introduced_by, value)
96}
97
98fn position_attr_key(position: Position<NodeId>, name: InodeAttrName) -> [u8; 17] {
99 let mut key = [0; 17];

Callers 1

canonical_effect_writersFunction · 0.85

Calls 3

invalid_attrFunction · 0.85
unwrapMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected