1use dcbor::prelude::*;
2
3use crate::UR;
4
5pub trait URDecodable: CBORTaggedDecodable {
7 fn from_ur(ur: impl AsRef<UR>) -> dcbor::Result<Self>
8 where
9 Self: Sized,
10 {
11 ur.as_ref().check_type(
12 Self::cbor_tags()[0].name().as_ref().unwrap().clone(),
13 )?;
14 Self::from_untagged_cbor(ur.as_ref().clone().into())
15 }
16
17 fn from_ur_string(ur_string: impl Into<String>) -> dcbor::Result<Self>
18 where
19 Self: Sized,
20 {
21 Self::from_ur(UR::from_ur_string(ur_string)?)
22 }
23}
24
25impl<T> URDecodable for T where T: CBORTaggedDecodable {}