Encode the canonical value as `(length, bytes)`.
(self)
| 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> { |