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

Function encode_operation_scope

atomic-core/src/operation/codec.rs:237–247  ·  view source on GitHub ↗

Encode a fixed-width operation-head scope key.

(scope: OperationScope)

Source from the content-addressed store, hash-verified

235
236/// Encode a fixed-width operation-head scope key.
237pub fn encode_operation_scope(scope: OperationScope) -> [u8; 17] {
238 let mut key = [0u8; 17];
239 match scope {
240 OperationScope::Repository => key[0] = OPERATION_SCOPE_REPOSITORY,
241 OperationScope::WorkingCopy(id) => {
242 key[0] = OPERATION_SCOPE_WORKING_COPY;
243 key[1..].copy_from_slice(id.as_bytes());
244 }
245 }
246 key
247}
248
249/// Decode and validate a fixed-width operation-head scope key.
250pub fn decode_operation_scope(bytes: &[u8; 17]) -> Result<OperationScope, OperationCodecError> {

Calls 1

as_bytesMethod · 0.45