custom.rs (604B)
1 use super::{CredentialId, CredentialIdErr}; 2 impl<'a: 'b, 'b> TryFrom<&'a [u8]> for CredentialId<&'b [u8]> { 3 type Error = CredentialIdErr; 4 #[inline] 5 fn try_from(value: &'a [u8]) -> Result<Self, Self::Error> { 6 Self::from_slice(value).map_err(CredentialIdErr::from) 7 } 8 } 9 impl TryFrom<Vec<u8>> for CredentialId<Vec<u8>> { 10 type Error = CredentialIdErr; 11 #[inline] 12 fn try_from(value: Vec<u8>) -> Result<Self, Self::Error> { 13 match CredentialId::<&[u8]>::try_from(value.as_slice()) { 14 Ok(_) => Ok(Self(value)), 15 Err(e) => Err(e), 16 } 17 } 18 }