Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/ur_decodable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ use dcbor::CBORTaggedDecodable;
/// A type that can be decoded from a UR.
pub trait URDecodable: CBORTaggedDecodable {
fn from_ur(ur: impl AsRef<UR>) -> Result<Self> where Self: Sized {
ur.as_ref().check_type(Self::cbor_tags()[0].name().as_ref().unwrap().clone())?;
Self::from_untagged_cbor(ur.as_ref().clone().into())
let tag = &Self::cbor_tags()[0];
if let Some(name) = tag.name().as_ref() {
ur.as_ref().check_type(name.clone())?;
Self::from_untagged_cbor(ur.as_ref().clone().into())
} else {
panic!("CBOR tag {} must have a name. Did you call `register_tags()`?", tag.value());
}
}

fn from_ur_string(ur_string: impl Into<String>) -> Result<Self> where Self: Sized {
Expand Down