@@ -5,7 +5,7 @@ mod tests;
55
66use std:: fmt:: Debug ;
77
8- use catalyst_signed_doc_spec:: payload:: Payload ;
8+ use catalyst_signed_doc_spec:: payload:: { Payload , Schema } ;
99use minicbor:: Encode ;
1010
1111use crate :: {
@@ -18,6 +18,8 @@ use crate::{
1818pub ( crate ) enum ContentSchema {
1919 /// Draft 7 JSON schema
2020 Json ( json_schema:: JsonSchema ) ,
21+ /// CDDL schema
22+ Cddl ,
2123}
2224
2325impl Debug for ContentSchema {
@@ -27,6 +29,7 @@ impl Debug for ContentSchema {
2729 ) -> std:: fmt:: Result {
2830 match self {
2931 Self :: Json ( _) => writeln ! ( f, "JsonSchema" ) ,
32+ Self :: Cddl => writeln ! ( f, "CddlSchema" ) ,
3033 }
3134 }
3235}
@@ -53,13 +56,14 @@ impl ContentRule {
5356 return Ok ( Self :: Nil ) ;
5457 }
5558
56- if let Some ( schema) = & spec. schema {
57- let schema_str = schema. to_string ( ) ;
58- Ok ( Self :: StaticSchema ( ContentSchema :: Json (
59- json_schema:: JsonSchema :: try_from ( & serde_json:: from_str ( & schema_str) ?) ?,
60- ) ) )
61- } else {
62- Ok ( Self :: NotNil )
59+ match & spec. schema {
60+ Some ( Schema :: JsonSchema ( schema) ) => {
61+ Ok ( Self :: StaticSchema ( ContentSchema :: Json (
62+ json_schema:: JsonSchema :: try_from ( schema) ?,
63+ ) ) )
64+ } ,
65+ Some ( Schema :: Cddl ( _) ) => Ok ( Self :: StaticSchema ( ContentSchema :: Cddl ) ) ,
66+ None => Ok ( Self :: NotNil ) ,
6367 }
6468 }
6569
@@ -75,6 +79,7 @@ impl ContentRule {
7579 ContentSchema :: Json ( json_schema) => {
7680 return Ok ( content_json_schema_check ( doc, json_schema) )
7781 } ,
82+ ContentSchema :: Cddl => return Ok ( true ) ,
7883 }
7984 }
8085 if let Self :: NotNil = self {
0 commit comments