Skip to content

Commit

Permalink
init branch
Browse files Browse the repository at this point in the history
  • Loading branch information
oriontvv committed Jan 15, 2025
1 parent e56ce6f commit e9458d7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ ron = "0.8.1"
serde = { version = "1.0.193", features = ["derive"] }
serde_json = "1.0.109"
serde_yaml = "0.9.34"
serde-xml-rs = "0.6.0"
toml = "0.8.19"

[dev-dependencies]
Expand Down
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use anyhow::Result;
use serde::Serialize;
use serde_xml_rs::{from_str, to_string};

#[derive(Debug, Copy, Clone, PartialEq, clap::ValueEnum)]
pub enum Format {
Expand All @@ -9,6 +10,7 @@ pub enum Format {
Ron,
Json5,
Bson,
Xml,
}

#[derive(Debug, Serialize)]
Expand All @@ -20,6 +22,7 @@ pub enum Value {
Ron(ron::Value),
Json5(serde_json::Value),
Bson(bson::Bson),
Xml(serde_xml_rs::ParserConfig),
}

pub fn load_input(input: &[u8], format: Format) -> Result<Value> {
Expand All @@ -33,6 +36,7 @@ pub fn load_input(input: &[u8], format: Format) -> Result<Value> {
Format::Ron => Value::Ron(ron::de::from_bytes(input)?),
Format::Json5 => Value::Json5(serde_json::from_slice(input)?),
Format::Bson => Value::Bson(bson::from_slice(input)?),
Format::Xml => Value::Xml(from_str()),
};
Ok(value)
}
Expand Down

0 comments on commit e9458d7

Please sign in to comment.