Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 86 additions & 4 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 @@ -24,6 +24,7 @@ homepage = "https://github.com/Bergmann89/xsd-parser"
[workspace.dependencies]
anyhow = "1.0"
base64 = "0.22"
const-hex = "1.17.0"
bit-set = "0.8"
bitflags = "2.7"
bytesize = "2.3"
Expand Down
21 changes: 16 additions & 5 deletions xsd-parser-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,34 @@ repository.workspace = true
all-features = true

[features]
default = [ ]
default = []
# Enable support for async `quick-xml` de-/serialization
async = [ "dep:futures", "dep:tokio", "quick-xml/async-tokio" ]
async = ["dep:futures", "dep:tokio", "quick-xml/async-tokio"]

# Enable support for base64 encoding/decoding
base64 = ["dep:base64"]

# Enable support for dynamic xml types
xml = [ "dep:indexmap", "dep:encoding_rs" ]
xml = ["dep:indexmap", "dep:encoding_rs"]

# Enable support for `quick-xml` de-/serialization
quick-xml = [ "xml", "dep:quick-xml", "dep:regex", "dep:thiserror" ]
quick-xml = [
"xml",
"dep:quick-xml",
"dep:regex",
"dep:thiserror",
"dep:const-hex",
"dep:base64",
]

[dependencies]
base64 = { workspace = true, optional = true }
const-hex = { workspace = true, optional = true }
encoding_rs = { workspace = true, optional = true }
futures = { workspace = true, optional = true }
indexmap = { workspace = true, optional = true }
num = { workspace = true, optional = true }
quick-xml = { workspace = true, optional = true, features = [ "encoding" ] }
quick-xml = { workspace = true, optional = true, features = ["encoding"] }
regex = { workspace = true, optional = true }
serde = { workspace = true, optional = true }
thiserror = { workspace = true, optional = true }
Expand Down
16 changes: 8 additions & 8 deletions xsd-parser-types/src/xml/any_simple_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ use num::{BigInt, BigRational, BigUint};
#[cfg(feature = "quick-xml")]
use quick_xml::events::Event;

use crate::quick_xml::{DeserializeBytes, SerializeBytes};
use crate::xml::NamespacesShared;

#[cfg(feature = "quick-xml")]
use crate::{
misc::{Namespace, NamespacePrefix},
Expand All @@ -19,10 +22,6 @@ use crate::{
SerializeHelper, Serializer, WithDeserializer, WithSerializer,
},
};
use crate::{
quick_xml::{DeserializeBytes, SerializeBytes},
xml::NamespacesShared,
};

use super::QName;

Expand All @@ -45,10 +44,10 @@ pub type Unsigned = BigUint;
pub type Unsigned = usize;

#[cfg(feature = "base64")]
pub type Base64Binary = Vec<u8>;
type Base64Binary = crate::xml::Base64Binary;

#[cfg(not(feature = "base64"))]
pub type Base64Binary = String;
type Base64Binary = crate::xml::Base64String;

/// Type that represents an `xs:anySimpleType` value.
#[derive(Debug, Clone)]
Expand Down Expand Up @@ -599,14 +598,15 @@ fn parse_base64_binary(bytes: &str) -> Result<Base64Binary, Error> {

Ok(BASE64_STANDARD
.decode(bytes)
.map_err(|_| ErrorKind::InvalidData(bytes.as_bytes().to_vec().into()))?)
.map_err(|_| ErrorKind::InvalidData(bytes.as_bytes().to_vec().into()))?
.into())
}

#[inline]
#[cfg(not(feature = "base64"))]
#[allow(clippy::unnecessary_wraps)]
fn parse_base64_binary(s: &str) -> Result<Base64Binary, Error> {
Ok(s.to_string())
Ok(s.to_string().into())
}

fn format_vec<X: Display>(items: &[X]) -> String {
Expand Down
Loading
Loading