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

Method canonical_bytes

atomic-core/src/change/attribute.rs:95–101  ·  view source on GitHub ↗

Encode the canonical value as `(length, bytes)`.

(self)

Source from the content-addressed store, hash-verified

93
94 /// Encode the canonical value as `(length, bytes)`.
95 pub fn canonical_bytes(self) -> Result<(u8, [u8; 2]), AttrValueError> {
96 self.validate()?;
97 Ok(match self {
98 Self::Mode(mode) => (2, mode.to_le_bytes()),
99 Self::Kind(kind) => (1, [kind.as_byte(), 0]),
100 })
101 }
102
103 /// Decode and validate a canonical value.
104 pub fn from_canonical(name: InodeAttrName, bytes: &[u8]) -> Result<Self, AttrValueError> {

Callers 3

publishFunction · 0.45
encode_inode_attr_eventFunction · 0.45

Calls 3

to_le_bytesMethod · 0.80
as_byteMethod · 0.80
validateMethod · 0.45

Tested by 1