File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
rust/signed_doc/src/metadata Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 11//! Catalyst Signed Document Metadata.
2+ use coset:: cbor:: Value ;
3+
24use super :: UuidV7 ;
35
46/// Reference to a Document.
@@ -19,11 +21,22 @@ pub enum DocumentRef {
1921 } ,
2022}
2123
22- impl TryFrom < & coset:: cbor:: Value > for DocumentRef {
24+ impl From < & DocumentRef > for Value {
25+ fn from ( val : & DocumentRef ) -> Self {
26+ match val {
27+ DocumentRef :: Latest { id } => Value :: from ( * id) ,
28+ DocumentRef :: WithVer { id, ver } => {
29+ Value :: Array ( vec ! [ Value :: from( * id) , Value :: from( * ver) ] )
30+ } ,
31+ }
32+ }
33+ }
34+
35+ impl TryFrom < & Value > for DocumentRef {
2336 type Error = anyhow:: Error ;
2437
2538 #[ allow( clippy:: indexing_slicing) ]
26- fn try_from ( val : & coset :: cbor :: Value ) -> anyhow:: Result < DocumentRef > {
39+ fn try_from ( val : & Value ) -> anyhow:: Result < DocumentRef > {
2740 if let Ok ( id) = UuidV7 :: try_from ( val) {
2841 Ok ( DocumentRef :: Latest { id } )
2942 } else {
You can’t perform that action at this time.
0 commit comments