-
Notifications
You must be signed in to change notification settings - Fork 100
feat!: introduce attrs setting
#949
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
Open
ericszentivanyi
wants to merge
8
commits into
oxidecomputer:main
Choose a base branch
from
ericszentivanyi:feat/introduce-attrs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
30aa5d9
feat: introduce `attrs` setting
ericszentivanyi 1e0de19
docs: describe `attrs` setting for `import_types!` macro
ericszentivanyi 733f4a3
chore(cli): add `additional_attrs` as an option
ericszentivanyi ee84b2c
docs(cli): describe `additional_attr` option
ericszentivanyi 1987326
test(cli): introduce test for `additional_attr`
ericszentivanyi 6dd93d5
chore: correct `strings_to_attrs`
ericszentivanyi db352a5
Merge branch 'main' into feat/introduce-attrs
ericszentivanyi 893f600
chore: convert `type_patch` into a struct with named fields
ericszentivanyi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,211 @@ | ||
| #![allow(clippy::redundant_closure_call)] | ||
| #![allow(clippy::needless_lifetimes)] | ||
| #![allow(clippy::match_single_binding)] | ||
| #![allow(clippy::clone_on_copy)] | ||
|
|
||
| #[doc = r" Error types."] | ||
| pub mod error { | ||
| #[doc = r" Error from a `TryFrom` or `FromStr` implementation."] | ||
| pub struct ConversionError(::std::borrow::Cow<'static, str>); | ||
| impl ::std::error::Error for ConversionError {} | ||
| impl ::std::fmt::Display for ConversionError { | ||
| fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { | ||
| ::std::fmt::Display::fmt(&self.0, f) | ||
| } | ||
| } | ||
| impl ::std::fmt::Debug for ConversionError { | ||
| fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { | ||
| ::std::fmt::Debug::fmt(&self.0, f) | ||
| } | ||
| } | ||
| impl From<&'static str> for ConversionError { | ||
| fn from(value: &'static str) -> Self { | ||
| Self(value.into()) | ||
| } | ||
| } | ||
| impl From<String> for ConversionError { | ||
| fn from(value: String) -> Self { | ||
| Self(value.into()) | ||
| } | ||
| } | ||
| } | ||
| #[doc = "`Fruit`"] | ||
| #[doc = r""] | ||
| #[doc = r" <details><summary>JSON schema</summary>"] | ||
| #[doc = r""] | ||
| #[doc = r" ```json"] | ||
| #[doc = "{"] | ||
| #[doc = " \"type\": \"object\","] | ||
| #[doc = " \"additionalProperties\": {"] | ||
| #[doc = " \"type\": \"string\""] | ||
| #[doc = " }"] | ||
| #[doc = "}"] | ||
| #[doc = r" ```"] | ||
| #[doc = r" </details>"] | ||
| #[extra_attr] | ||
| #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] | ||
| #[serde(transparent)] | ||
| pub struct Fruit(pub ::std::collections::HashMap<::std::string::String, ::std::string::String>); | ||
| impl ::std::ops::Deref for Fruit { | ||
| type Target = ::std::collections::HashMap<::std::string::String, ::std::string::String>; | ||
| fn deref(&self) -> &::std::collections::HashMap<::std::string::String, ::std::string::String> { | ||
| &self.0 | ||
| } | ||
| } | ||
| impl ::std::convert::From<Fruit> | ||
| for ::std::collections::HashMap<::std::string::String, ::std::string::String> | ||
| { | ||
| fn from(value: Fruit) -> Self { | ||
| value.0 | ||
| } | ||
| } | ||
| impl ::std::convert::From<&Fruit> for Fruit { | ||
| fn from(value: &Fruit) -> Self { | ||
| value.clone() | ||
| } | ||
| } | ||
| impl ::std::convert::From<::std::collections::HashMap<::std::string::String, ::std::string::String>> | ||
| for Fruit | ||
| { | ||
| fn from( | ||
| value: ::std::collections::HashMap<::std::string::String, ::std::string::String>, | ||
| ) -> Self { | ||
| Self(value) | ||
| } | ||
| } | ||
| #[doc = "`FruitOrVeg`"] | ||
| #[doc = r""] | ||
| #[doc = r" <details><summary>JSON schema</summary>"] | ||
| #[doc = r""] | ||
| #[doc = r" ```json"] | ||
| #[doc = "{"] | ||
| #[doc = " \"oneOf\": ["] | ||
| #[doc = " {"] | ||
| #[doc = " \"title\": \"veg\","] | ||
| #[doc = " \"anyOf\": ["] | ||
| #[doc = " {"] | ||
| #[doc = " \"$ref\": \"#/defs/veggie\""] | ||
| #[doc = " }"] | ||
| #[doc = " ]"] | ||
| #[doc = " },"] | ||
| #[doc = " {"] | ||
| #[doc = " \"title\": \"fruit\","] | ||
| #[doc = " \"anyOf\": ["] | ||
| #[doc = " {"] | ||
| #[doc = " \"$ref\": \"#/defs/fruit\""] | ||
| #[doc = " }"] | ||
| #[doc = " ]"] | ||
| #[doc = " }"] | ||
| #[doc = " ]"] | ||
| #[doc = "}"] | ||
| #[doc = r" ```"] | ||
| #[doc = r" </details>"] | ||
| #[extra_attr] | ||
| #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] | ||
| #[serde(untagged)] | ||
| pub enum FruitOrVeg { | ||
| Veg(Veggie), | ||
| Fruit(Fruit), | ||
| } | ||
| impl ::std::convert::From<&Self> for FruitOrVeg { | ||
| fn from(value: &FruitOrVeg) -> Self { | ||
| value.clone() | ||
| } | ||
| } | ||
| impl ::std::convert::From<Veggie> for FruitOrVeg { | ||
| fn from(value: Veggie) -> Self { | ||
| Self::Veg(value) | ||
| } | ||
| } | ||
| impl ::std::convert::From<Fruit> for FruitOrVeg { | ||
| fn from(value: Fruit) -> Self { | ||
| Self::Fruit(value) | ||
| } | ||
| } | ||
| #[doc = "`Veggie`"] | ||
| #[doc = r""] | ||
| #[doc = r" <details><summary>JSON schema</summary>"] | ||
| #[doc = r""] | ||
| #[doc = r" ```json"] | ||
| #[doc = "{"] | ||
| #[doc = " \"type\": \"object\","] | ||
| #[doc = " \"required\": ["] | ||
| #[doc = " \"veggieLike\","] | ||
| #[doc = " \"veggieName\""] | ||
| #[doc = " ],"] | ||
| #[doc = " \"properties\": {"] | ||
| #[doc = " \"veggieLike\": {"] | ||
| #[doc = " \"description\": \"Do I like this vegetable?\","] | ||
| #[doc = " \"type\": \"boolean\""] | ||
| #[doc = " },"] | ||
| #[doc = " \"veggieName\": {"] | ||
| #[doc = " \"description\": \"The name of the vegetable.\","] | ||
| #[doc = " \"type\": \"string\""] | ||
| #[doc = " }"] | ||
| #[doc = " }"] | ||
| #[doc = "}"] | ||
| #[doc = r" ```"] | ||
| #[doc = r" </details>"] | ||
| #[extra_attr] | ||
| #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] | ||
| pub struct Veggie { | ||
| #[doc = "Do I like this vegetable?"] | ||
| #[serde(rename = "veggieLike")] | ||
| pub veggie_like: bool, | ||
| #[doc = "The name of the vegetable."] | ||
| #[serde(rename = "veggieName")] | ||
| pub veggie_name: ::std::string::String, | ||
| } | ||
| impl ::std::convert::From<&Veggie> for Veggie { | ||
| fn from(value: &Veggie) -> Self { | ||
| value.clone() | ||
| } | ||
| } | ||
| #[doc = "A representation of a person, company, organization, or place"] | ||
| #[doc = r""] | ||
| #[doc = r" <details><summary>JSON schema</summary>"] | ||
| #[doc = r""] | ||
| #[doc = r" ```json"] | ||
| #[doc = "{"] | ||
| #[doc = " \"$id\": \"https://example.com/arrays.schema.json\","] | ||
| #[doc = " \"title\": \"veggies\","] | ||
| #[doc = " \"description\": \"A representation of a person, company, organization, or place\","] | ||
| #[doc = " \"type\": \"object\","] | ||
| #[doc = " \"properties\": {"] | ||
| #[doc = " \"fruits\": {"] | ||
| #[doc = " \"type\": \"array\","] | ||
| #[doc = " \"items\": {"] | ||
| #[doc = " \"type\": \"string\""] | ||
| #[doc = " }"] | ||
| #[doc = " },"] | ||
| #[doc = " \"vegetables\": {"] | ||
| #[doc = " \"type\": \"array\","] | ||
| #[doc = " \"items\": {"] | ||
| #[doc = " \"$ref\": \"#/$defs/veggie\""] | ||
| #[doc = " }"] | ||
| #[doc = " }"] | ||
| #[doc = " }"] | ||
| #[doc = "}"] | ||
| #[doc = r" ```"] | ||
| #[doc = r" </details>"] | ||
| #[extra_attr] | ||
| #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] | ||
| pub struct Veggies { | ||
| #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] | ||
| pub fruits: ::std::vec::Vec<::std::string::String>, | ||
| #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] | ||
| pub vegetables: ::std::vec::Vec<Veggie>, | ||
| } | ||
| impl ::std::convert::From<&Veggies> for Veggies { | ||
| fn from(value: &Veggies) -> Self { | ||
| value.clone() | ||
| } | ||
| } | ||
| impl ::std::default::Default for Veggies { | ||
| fn default() -> Self { | ||
| Self { | ||
| fruits: Default::default(), | ||
| vegetables: Default::default(), | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the shorthand for the
additional-deriveoption to resolve the conflict with the newadditional-attroption. This is a breaking change.