@@ -11,7 +11,9 @@ pub use crate::ConfigFormat;
1111#[ non_exhaustive]
1212pub enum InputFormat {
1313 Xml ,
14+ #[ cfg( feature = "yaml" ) ]
1415 Yaml ,
16+ #[ cfg( feature = "json" ) ]
1517 Json ,
1618}
1719
@@ -20,7 +22,9 @@ impl FromStr for InputFormat {
2022 fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
2123 match s {
2224 "svd" | "SVD" | "xml" | "XML" => Ok ( Self :: Xml ) ,
25+ #[ cfg( feature = "yaml" ) ]
2326 "yml" | "yaml" | "YAML" => Ok ( Self :: Yaml ) ,
27+ #[ cfg( feature = "json" ) ]
2428 "json" | "JSON" => Ok ( Self :: Json ) ,
2529 _ => Err ( anyhow ! ( "Unknown input file format" ) ) ,
2630 }
@@ -31,7 +35,9 @@ impl FromStr for InputFormat {
3135#[ non_exhaustive]
3236pub enum OutputFormat {
3337 Xml ,
38+ #[ cfg( feature = "yaml" ) ]
3439 Yaml ,
40+ #[ cfg( feature = "json" ) ]
3541 Json ,
3642}
3743
@@ -40,7 +46,9 @@ impl FromStr for OutputFormat {
4046 fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
4147 match s {
4248 "svd" | "SVD" | "xml" | "XML" => Ok ( Self :: Xml ) ,
49+ #[ cfg( feature = "yaml" ) ]
4350 "yml" | "yaml" | "YAML" => Ok ( Self :: Yaml ) ,
51+ #[ cfg( feature = "json" ) ]
4452 "json" | "JSON" => Ok ( Self :: Json ) ,
4553 _ => Err ( anyhow ! ( "Unknown output file format" ) ) ,
4654 }
@@ -75,7 +83,9 @@ pub fn open_svd(
7583 & input,
7684 & svd_parser:: Config :: default ( ) . ignore_enums ( parser_config. ignore_enums ) ,
7785 ) ?,
86+ #[ cfg( feature = "yaml" ) ]
7887 InputFormat :: Yaml => serde_yaml:: from_str ( & input) ?,
88+ #[ cfg( feature = "json" ) ]
7989 InputFormat :: Json => serde_json:: from_str ( & input) ?,
8090 } ;
8191 if parser_config. expand_properties {
@@ -111,7 +121,9 @@ pub fn convert(
111121
112122 let output = match output_format {
113123 OutputFormat :: Xml => svd_encoder:: encode_with_config ( & device, & config) ?,
124+ #[ cfg( feature = "yaml" ) ]
114125 OutputFormat :: Yaml => serde_yaml:: to_string ( & device) ?,
126+ #[ cfg( feature = "json" ) ]
115127 OutputFormat :: Json => serde_json:: to_string_pretty ( & device) ?,
116128 } ;
117129
0 commit comments