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

Method from_base32

atomic-identity/src/delegation.rs:614–619  ·  view source on GitHub ↗

Parse a base32 rendering, with or without the `urn:atomic:delegation:` prefix.

(s: &str)

Source from the content-addressed store, hash-verified

612 /// Parse a base32 rendering, with or without the `urn:atomic:delegation:`
613 /// prefix.
614 pub fn from_base32(s: &str) -> Option<Self> {
615 let raw = s.strip_prefix(Self::URN_PREFIX).unwrap_or(s);
616 let bytes = data_encoding::BASE32_NOPAD.decode(raw.as_bytes()).ok()?;
617 let bytes: [u8; 32] = bytes.try_into().ok()?;
618 Some(Self(bytes))
619 }
620
621 /// The canonical URN form (`urn:atomic:delegation:<base32>`).
622 pub fn to_urn(&self) -> String {

Callers

nothing calls this directly

Calls 3

okMethod · 0.45
decodeMethod · 0.45
as_bytesMethod · 0.45

Tested by

no test coverage detected