core: add documentation to `RepoId::from_canonical`

This commit is contained in:
Fintan Halpenny 2026-02-10 09:22:07 +00:00 committed by Lorenz Leutgeb
parent 35a01898e6
commit aeba81f4d9
1 changed files with 9 additions and 0 deletions

View File

@ -96,6 +96,15 @@ impl RepoId {
multibase::encode(multibase::Base::Base58Btc, AsRef::<[u8]>::as_ref(&self.0))
}
/// Decode the input string into a [`RepoId`].
///
/// # Errors
///
/// - The [multibase] decoding fails
/// - The decoded [multibase] code does not match any expected multibase code
/// - The input exceeds the expected number of bytes, post multibase decoding
///
/// [multibase]: https://github.com/multiformats/multibase?tab=readme-ov-file#multibase-table
pub fn from_canonical(input: &str) -> Result<Self, IdError> {
const EXPECTED_LEN: usize = 20;
let (base, bytes) = multibase::decode(input)?;