diff --git a/cdevents-sdk/Cargo.toml b/cdevents-sdk/Cargo.toml index a90cacb..ff28296 100644 --- a/cdevents-sdk/Cargo.toml +++ b/cdevents-sdk/Cargo.toml @@ -11,7 +11,7 @@ description = "A Rust SDK for CDEvents" [dependencies] cloudevents-sdk = { version = "0.7", optional = true, default-features = false } -fluent-uri = "0.1" +fluent-uri = "0.2" proptest = { version = "1.4", optional = true } proptest-derive = { version = "0.5", optional = true } serde = { version = "1.0", features = ["derive"] } diff --git a/cdevents-sdk/src/error.rs b/cdevents-sdk/src/error.rs index 51ac340..acf0c47 100644 --- a/cdevents-sdk/src/error.rs +++ b/cdevents-sdk/src/error.rs @@ -7,7 +7,7 @@ pub enum Error { #[error("Empty data in cloudevent")] DataNotFoundInCloudEvent, #[error(transparent)] - UriParseError( #[from] fluent_uri::ParseError), + UriParseError( #[from] fluent_uri::error::ParseError), #[error(transparent)] SerdeJsonError( #[from] serde_json::Error), #[error("unknown error")] diff --git a/cdevents-sdk/src/serde.rs b/cdevents-sdk/src/serde.rs index e225c2f..c606c1a 100644 --- a/cdevents-sdk/src/serde.rs +++ b/cdevents-sdk/src/serde.rs @@ -29,15 +29,15 @@ pub(crate) mod datetime { pub(crate) mod fluent_uri { use serde::{de::Error, Deserialize, Deserializer, Serializer}; - pub fn deserialize<'de, D>(deserializer: D) -> Result, D::Error> + pub fn deserialize<'de, D>(deserializer: D) -> Result, D::Error> where D: Deserializer<'de>, { let txt = String::deserialize(deserializer)?; - fluent_uri::Uri::parse_from(txt).map_err(|e| D::Error::custom(e.1)) + fluent_uri::UriRef::parse(txt).map_err(D::Error::custom) } - pub fn serialize(input: &fluent_uri::Uri, serializer: S) -> Result + pub fn serialize(input: &fluent_uri::UriRef, serializer: S) -> Result where S: Serializer, { diff --git a/cdevents-sdk/src/uri.rs b/cdevents-sdk/src/uri.rs index d3914ea..59b670c 100644 --- a/cdevents-sdk/src/uri.rs +++ b/cdevents-sdk/src/uri.rs @@ -1,4 +1,4 @@ -// wrapper for fluent_uri::Uri to allow for restristed set of operations +// wrapper for fluent_uri::UriRef to allow for restristed set of operations // and to complete currently missing features. // Why fluent_uri? // - support uri & uri-reference, preserve the original string, but young, doesn't impl PartialEq,... @@ -14,9 +14,9 @@ use crate::UriReference; #[derive(Debug, Clone, Default, Serialize, Deserialize)] #[cfg_attr(feature = "testkit", derive(Arbitrary))] pub struct Uri( - #[cfg_attr(feature = "testkit", proptest(value = "fluent_uri::Uri::parse_from(\"https://example.com/\".to_owned()).unwrap()"))] //TODO generate random value + #[cfg_attr(feature = "testkit", proptest(value = "fluent_uri::UriRef::parse(\"https://example.com/\".to_owned()).unwrap()"))] //TODO generate random value #[serde(with = "crate::serde::fluent_uri")] - pub(crate) fluent_uri::Uri + pub(crate) fluent_uri::UriRef ); impl PartialEq for Uri { @@ -32,7 +32,7 @@ impl FromStr for Uri { fn from_str(s: &str) -> Result { //TODO check it's not a reference URI - fluent_uri::Uri::parse_from(s.to_owned()).map_err(|(_,e)| e.into()).map(Uri) + fluent_uri::UriRef::parse(s.to_owned()).map_err(Self::Err::from).map(Uri) } } @@ -48,7 +48,7 @@ impl TryFrom<&str> for Uri { type Error = crate::Error; fn try_from(s: &str) -> Result { - fluent_uri::Uri::parse_from(s.to_owned()).map_err(|(_,e)| e.into()).map(Uri) + fluent_uri::UriRef::parse(s.to_owned()).map_err(Self::Error::from).map(Uri) } } @@ -56,7 +56,7 @@ impl TryFrom for Uri { type Error = crate::Error; fn try_from(s: String) -> Result { - fluent_uri::Uri::parse_from(s).map_err(|(_,e)| e.into()).map(Uri) + fluent_uri::UriRef::parse(s).map_err(Self::Error::from).map(Uri) } } @@ -72,7 +72,7 @@ impl Uri { } } -// impl From for fluent_uri::Uri { +// impl From for fluent_uri::UriRef { // fn from(uri: Uri) -> Self { // uri.0 // } diff --git a/cdevents-sdk/src/uri_reference.rs b/cdevents-sdk/src/uri_reference.rs index edd3d2a..58952ef 100644 --- a/cdevents-sdk/src/uri_reference.rs +++ b/cdevents-sdk/src/uri_reference.rs @@ -6,7 +6,7 @@ use crate::Uri; #[derive(Debug, Clone, Default, Serialize, Deserialize)] pub struct UriReference( #[serde(with = "crate::serde::fluent_uri")] - pub(crate) fluent_uri::Uri + pub(crate) fluent_uri::UriRef ); impl PartialEq for UriReference { @@ -21,7 +21,7 @@ impl FromStr for UriReference { type Err = crate::Error; fn from_str(s: &str) -> Result { - fluent_uri::Uri::parse_from(s.to_owned()).map_err(|(_,e)| e.into()).map(UriReference) + fluent_uri::UriRef::parse(s.to_owned()).map_err(Self::Err::from).map(UriReference) } } @@ -37,7 +37,7 @@ impl TryFrom<&str> for UriReference { type Error = crate::Error; fn try_from(s: &str) -> Result { - fluent_uri::Uri::parse_from(s.to_owned()).map_err(|(_,e)| e.into()).map(UriReference) + fluent_uri::UriRef::parse(s.to_owned()).map_err(Self::Error::from).map(UriReference) } } @@ -45,7 +45,7 @@ impl TryFrom for UriReference { type Error = crate::Error; fn try_from(s: String) -> Result { - fluent_uri::Uri::parse_from(s).map_err(|(_,e)| e.into()).map(UriReference) + fluent_uri::UriRef::parse(s).map_err(Self::Error::from).map(UriReference) } } @@ -61,7 +61,7 @@ impl UriReference { } } -// impl From for fluent_uri::Uri { +// impl From for fluent_uri::UriRef { // fn from(uri: UriReference) -> Self { // uri.0 // } diff --git a/cdevents-sdk/tests/specs.rs b/cdevents-sdk/tests/specs.rs index 0cfc232..bc2c636 100644 --- a/cdevents-sdk/tests/specs.rs +++ b/cdevents-sdk/tests/specs.rs @@ -90,7 +90,7 @@ fn can_serde_example(#[files("../cdevents-specs/spec-*/examples/*.json")] #[file // "https://example.org" // rhs: // "https://example.org/" - // But it's not the case with fluent_uri::Uri + // But it's not the case with fluent_uri::UriRef // // example_txt = example_txt.replace("\"https://example.org\"", "\"https://example.org/\""); diff --git a/tools/cargo-deny/deny.toml b/tools/cargo-deny/deny.toml index 003c92a..278ac5d 100644 --- a/tools/cargo-deny/deny.toml +++ b/tools/cargo-deny/deny.toml @@ -7,7 +7,7 @@ wildcards = "deny" [licenses] confidence-threshold = 0.95 -allow = ["Apache-2.0", "MIT", "Unicode-DFS-2016"] +allow = ["Apache-2.0", "MIT", "MIT-0", "Unicode-DFS-2016"] exceptions = [] # The unpublished packages (generator) would be ignored now