File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
rust/catalyst-signed-doc-macro/src Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 11//! Structs for JSON fields.
2+ use proc_macro2:: TokenStream ;
3+ use quote:: quote;
24
35/// "required" field definition
46#[ derive( serde:: Deserialize ) ]
@@ -10,6 +12,22 @@ pub(crate) enum IsRequired {
1012 Optional ,
1113}
1214
15+ impl TryInto < TokenStream > for IsRequired {
16+ type Error = anyhow:: Error ;
17+
18+ fn try_into ( self ) -> Result < TokenStream , Self :: Error > {
19+ match self {
20+ Self :: Yes => Ok ( quote ! { true } ) ,
21+ Self :: Optional => Ok ( quote ! { false } ) ,
22+ Self :: Excluded => {
23+ return Ok ( quote ! {
24+ crate :: validator:: rules:: RefRule :: NotSpecified
25+ } ) ;
26+ } ,
27+ }
28+ }
29+ }
30+
1331/// Document's metadata fields definition
1432#[ derive( serde:: Deserialize ) ]
1533#[ allow( clippy:: missing_docs_in_private_items) ]
You can’t perform that action at this time.
0 commit comments