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

Method from_slice

atomic-identity/src/signing.rs:57–65  ·  view source on GitHub ↗

Create a signature from a byte slice.

(bytes: &[u8])

Source from the content-addressed store, hash-verified

55
56 /// Create a signature from a byte slice.
57 pub fn from_slice(bytes: &[u8]) -> Result<Self, IdentityError> {
58 if bytes.len() != SIGNATURE_SIZE {
59 return Err(IdentityError::InvalidSignature);
60 }
61
62 let mut arr = [0u8; SIGNATURE_SIZE];
63 arr.copy_from_slice(bytes);
64 Ok(Signature(arr))
65 }
66
67 /// Get the raw bytes of the signature.
68 pub fn as_bytes(&self) -> &[u8; SIGNATURE_SIZE] {

Callers

nothing calls this directly

Calls 2

SignatureClass · 0.85
lenMethod · 0.45

Tested by

no test coverage detected