1- //! `RefRule ` generation
1+ //! `ContentTypeRule ` generation
22
33use proc_macro2:: TokenStream ;
44use quote:: quote;
55
66use crate :: signed_doc_spec:: { self , IsRequired } ;
77
8- /// Generating `RefRule ` instantiation
9- pub ( crate ) fn rule (
8+ /// Generating `ContentTypeRule ` instantiation
9+ pub ( crate ) fn into_rule (
1010 content_type : & signed_doc_spec:: content_type:: ContentType
1111) -> anyhow:: Result < TokenStream > {
1212 if matches ! ( content_type. required, IsRequired :: Excluded ) {
@@ -25,25 +25,25 @@ pub(crate) fn rule(
2525 }
2626
2727 let exp = match content_type. value . as_str ( ) {
28- "application/cbor" => quote ! { ContentTypeRule :: Cbor } ,
29- "application/cddl" => quote ! { ContentTypeRule :: Cddl } ,
30- "application/json" => quote ! { ContentTypeRule :: Json } ,
31- "application/json+schema" => quote ! { ContentTypeRule :: JsonSchema } ,
32- "text/css; charset=utf-8" => quote ! { ContentTypeRule :: Css } ,
28+ "application/cbor" => quote ! { ContentType :: Cbor } ,
29+ "application/cddl" => quote ! { ContentType :: Cddl } ,
30+ "application/json" => quote ! { ContentType :: Json } ,
31+ "application/json+schema" => quote ! { ContentType :: JsonSchema } ,
32+ "text/css; charset=utf-8" => quote ! { ContentType :: Css } ,
3333 "text/css; charset=utf-8; template=handlebars" => {
34- quote ! { ContentTypeRule :: CssHandlebars }
34+ quote ! { ContentType :: CssHandlebars }
3535 } ,
36- "text/html; charset=utf-8" => quote ! { ContentTypeRule :: Html } ,
36+ "text/html; charset=utf-8" => quote ! { ContentType :: Html } ,
3737 "text/html; charset=utf-8; template=handlebars" => {
38- quote ! { ContentTypeRule :: HtmlHandlebars }
38+ quote ! { ContentType :: HtmlHandlebars }
3939 } ,
40- "text/markdown; charset=utf-8" => quote ! { ContentTypeRule :: Markdown } ,
40+ "text/markdown; charset=utf-8" => quote ! { ContentType :: Markdown } ,
4141 "text/markdown; charset=utf-8; template=handlebars" => {
42- quote ! { ContentTypeRule :: MarkdownHandlebars }
42+ quote ! { ContentType :: MarkdownHandlebars }
4343 } ,
44- "text/plain; charset=utf-8" => quote ! { ContentTypeRule :: Plain } ,
44+ "text/plain; charset=utf-8" => quote ! { ContentType :: Plain } ,
4545 "text/plain; charset=utf-8; template=handlebars" => {
46- quote ! { ContentTypeRule :: PlainHandlebars }
46+ quote ! { ContentType :: PlainHandlebars }
4747 } ,
4848 _ => {
4949 return Err ( anyhow:: anyhow!(
@@ -55,7 +55,7 @@ pub(crate) fn rule(
5555
5656 Ok ( quote ! {
5757 crate :: validator:: rules:: ContentTypeRule :: Specified {
58- exp: crate :: validator :: rules :: #exp,
58+ exp: #exp,
5959 }
6060 } )
6161}
0 commit comments