Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps): update fluent-uri requirement from 0.1 to 0.2 #31

Merged
merged 3 commits into from
Aug 31, 2024
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
2 changes: 1 addition & 1 deletion cdevents-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
2 changes: 1 addition & 1 deletion cdevents-sdk/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>),
#[error(transparent)]
SerdeJsonError( #[from] serde_json::Error),
#[error("unknown error")]
Expand Down
6 changes: 3 additions & 3 deletions cdevents-sdk/src/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<fluent_uri::Uri<String>, D::Error>
pub fn deserialize<'de, D>(deserializer: D) -> Result<fluent_uri::UriRef<String>, 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<S>(input: &fluent_uri::Uri<String>, serializer: S) -> Result<S::Ok, S::Error>
pub fn serialize<S>(input: &fluent_uri::UriRef<String>, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
Expand Down
14 changes: 7 additions & 7 deletions cdevents-sdk/src/uri.rs
Original file line number Diff line number Diff line change
@@ -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,...
Expand All @@ -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<String>
pub(crate) fluent_uri::UriRef<String>
);

impl PartialEq for Uri {
Expand All @@ -32,7 +32,7 @@ impl FromStr for Uri {

fn from_str(s: &str) -> Result<Self, Self::Err> {
//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)
}
}

Expand All @@ -48,15 +48,15 @@ impl TryFrom<&str> for Uri {
type Error = crate::Error;

fn try_from(s: &str) -> Result<Self, Self::Error> {
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)
}
}

impl TryFrom<String> for Uri {
type Error = crate::Error;

fn try_from(s: String) -> Result<Self, Self::Error> {
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)
}
}

Expand All @@ -72,7 +72,7 @@ impl Uri {
}
}

// impl From<Uri> for fluent_uri::Uri<String> {
// impl From<Uri> for fluent_uri::UriRef<String> {
// fn from(uri: Uri) -> Self {
// uri.0
// }
Expand Down
10 changes: 5 additions & 5 deletions cdevents-sdk/src/uri_reference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>
pub(crate) fluent_uri::UriRef<String>
);

impl PartialEq for UriReference {
Expand All @@ -21,7 +21,7 @@ impl FromStr for UriReference {
type Err = crate::Error;

fn from_str(s: &str) -> Result<Self, Self::Err> {
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)
}
}

Expand All @@ -37,15 +37,15 @@ impl TryFrom<&str> for UriReference {
type Error = crate::Error;

fn try_from(s: &str) -> Result<Self, Self::Error> {
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)
}
}

impl TryFrom<String> for UriReference {
type Error = crate::Error;

fn try_from(s: String) -> Result<Self, Self::Error> {
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)
}
}

Expand All @@ -61,7 +61,7 @@ impl UriReference {
}
}

// impl From<UriReference> for fluent_uri::Uri<String> {
// impl From<UriReference> for fluent_uri::UriRef<String> {
// fn from(uri: UriReference) -> Self {
// uri.0
// }
Expand Down
2 changes: 1 addition & 1 deletion cdevents-sdk/tests/specs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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/\"");

Expand Down
2 changes: 1 addition & 1 deletion tools/cargo-deny/deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down