Parse a base32 rendering, with or without the `urn:atomic:delegation:` prefix.
(s: &str)
| 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 { |