diff --git a/.editorconfig b/.editorconfig index 8f411f9..e221a3c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -17,13 +17,6 @@ indent_size = 2 #inside code block, indentation could be anything indent_size = unset -[*.py] -indent_size = 4 -# 88 is the default for black formatter -# 79 is PEP8's recommendation -# 119 is django's recommendation -max_line_length = 88 - [*.rs] # https://github.com/rust-dev-tools/fmt-rfcs/blob/master/guide/guide.md indent_size = 4 @@ -33,11 +26,6 @@ max_line_length = 200 [{*.bazel,*.bzl,BUILD,WORKSPACE}] indent_size = 4 -[*.java] -# try to align with https://github.com/diffplug/spotless (https://github.com/google/google-java-format) -indent_size = 4 -max_line_length = 100 - # The JSON files contain newlines inconsistently [*.json] insert_final_newline = unset diff --git a/Cargo.toml b/Cargo.toml index 8609fad..d01b1f1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,10 @@ members = ["cdevents-sdk", "generator"] [workspace.package] edition = "2021" version = "0.1.0" -authors = ["David Bernard"] +authors = [ + # The actual list of contributors can be retrieved from the git log + "The CDEvents Rust SDK Authors", +] license = "ASL-2.0" repository = "https://github.com/cdevents/sdk-rust" rust-version = "1.75" diff --git a/README.md b/README.md index 5dc967b..3905ac3 100644 --- a/README.md +++ b/README.md @@ -68,4 +68,4 @@ If you would like to contribute, see our [development](DEVELOPMENT.md) guide. - [CDEvents](https://cdevents.dev) - [CDEvents Primer](https://cdevents.dev/docs/primer/) -- [CDFoundation Specification](https://cdevents.dev/docs/) +- [CDEvents Specification](https://cdevents.dev/docs/) diff --git a/cdevents-sdk/Cargo.toml b/cdevents-sdk/Cargo.toml index 0369ffc..715aafb 100644 --- a/cdevents-sdk/Cargo.toml +++ b/cdevents-sdk/Cargo.toml @@ -10,9 +10,7 @@ publish = true [dependencies] cloudevents-sdk = { version = "0.7", optional = true, default-features = false } -fluent-uri = "0.1" # support uri & uri-reference, preserve the original string, but young, doesn't impl PartialEq,... -# http = "1" # doesn't support uri-reference -# http-serde = "2" +fluent-uri = "0.1" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" thiserror = "1.0" diff --git a/cdevents-sdk/src/serde.rs b/cdevents-sdk/src/serde.rs index 6865b3d..e225c2f 100644 --- a/cdevents-sdk/src/serde.rs +++ b/cdevents-sdk/src/serde.rs @@ -26,69 +26,6 @@ pub(crate) mod datetime { } } -// pub(crate) fn ok_or_none<'de, D, T>(deserializer: D) -> Result, D::Error> -// where -// D: Deserializer<'de>, -// T: Deserialize<'de>, -// { -// let v = Value::deserialize(deserializer)?; -// Ok(T::deserialize(v).ok()) -// } - -// pub(crate) mod ok_or_none { -// use serde::{Deserialize, Deserializer, Serializer}; - -// pub fn deserialize<'de, D, T>(deserializer: D) -> Result, D::Error> -// where -// D: Deserializer<'de>, -// T: Deserialize<'de>, -// { -// let v = Option::deserialize(deserializer)?; -// Ok(T::deserialize(v).ok()) -// } - -// pub fn serialize( -// input: &Option>, -// serializer: S, -// ) -> Result -// where -// S: Serializer, -// { -// match input { -// None => serializer.serialize_none(), -// Some(input) => crate::serde::uri_reference::serialize(input, serializer), -// } -// } -// } - -// pub(crate) mod uri_reference_optional { -// use serde::{Deserialize, Deserializer, Serializer}; - -// #[derive(Deserialize)] -// struct Wrapper(#[serde(with = "crate::serde::uri_reference")] fluent_uri::Uri); - -// pub fn deserialize<'de, D>(deserializer: D) -> Result>, D::Error> -// where -// D: Deserializer<'de>, -// { -// let v = Option::deserialize(deserializer)?; -// Ok(v.map(|Wrapper(a)| a)) -// } - -// pub fn serialize( -// input: &Option>, -// serializer: S, -// ) -> Result -// where -// S: Serializer, -// { -// match input { -// None => serializer.serialize_none(), -// Some(input) => crate::serde::uri_reference::serialize(input, serializer), -// } -// } -// } - pub(crate) mod fluent_uri { use serde::{de::Error, Deserialize, Deserializer, Serializer}; diff --git a/cdevents-sdk/src/uri.rs b/cdevents-sdk/src/uri.rs index 0c5fd4a..bf65638 100644 --- a/cdevents-sdk/src/uri.rs +++ b/cdevents-sdk/src/uri.rs @@ -1,6 +1,9 @@ // wrapper for fluent_uri::Uri to allow for restristed set of operations // and to complete currently missing features. -//TODO impl the check difference for URI and Uri +// Why fluent_uri? +// - support uri & uri-reference, preserve the original string, but young, doesn't impl PartialEq,... +// - http::Uri, more mature, but doesn't support uri-reference, and normalize url when generate string +//TODO impl the check difference for Uri and Uri-reference use std::str::FromStr; diff --git a/generator/README.md b/generator/README.md index 3760e75..fe1efa0 100644 --- a/generator/README.md +++ b/generator/README.md @@ -8,8 +8,8 @@ Goals: generate rust code for cdevents from jsonschema provided as part of cdeve ## Why not use a jsonschema to rust generator? -- I tried some (like ) and they failed (no error), maybe too early, not support for the version of jsonschema used by cdevents (often they support jsonschema draft-4) -- The json schema (v0.3) are not connected, so lot of duplication (context,...), so classical generator will create as many Context type as Event type,... +- I tried some and they failed (no error), maybe too early, not support for the version of jsonschema used by cdevents (often they support jsonschema draft-4) +- The json schema (v0.3) are not connected, so lot of duplication (context,...), so classical generators will create as many Context type as Event type,... Our implementation only part of the schema is extracted to generate what is different aka the `content` of subjects. ## Run