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

Implement serde_with::SerializeAs and serde_with ::DeserializeAs for ArrayVec #249

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kraktus
Copy link

@kraktus kraktus commented Sep 29, 2023

serde_with is a widely used crate (24M downloads) to allow custom (de)serialisation.

This commit allow to use Arrayvec as a container in the serde_with::serde_as macro.

#[serde_as]
#[derive(Serialize, Deserialize)]
pub struct Native {
    #[serde_as(as = "ArrayVec<DisplayFromStr,128>")]
    pub sans: ArrayVec<TypeWithoutSerde, 128>,
}

I've it included under the serde feature, but it can be on its own feature.

If this is deemed to niche to include, an alternative would be to include it directly in the serde_with crate under a feature flag, similar to what is done for other popular library, such as hashbrown_0_14 or chrono_0_4. It has the disadvantage of pinning to one version.

`serde_with` is a widely used crate (24M downloads) to allow custom (de)serialisation.

This commit allow to use Arrayvec as a container in the `serde_with::serde_as` macro.

```rust
#[serde_as]
#[derive(Serialize, Deserialize)]
pub struct Native {
    #[serde_as(as = "ArrayVec<DisplayFromStr,128>")]
    pub sans: ArrayVec<TypeWithoutSerde, 128>,
}
```

I've it included under the `serde` feature, but it can be on its own feature.

If this is deemed to niche to include, an alternative would be to include it directly in the `serde_with` crate under a feature flag, similar to what is done for other popular library, such as `hashbrown_0_14` or `chrono_0_4`. It has the disadvantage of pinning to one version.
@kraktus kraktus changed the title Implement SerializeAs and DeserializeAs for ArrayVec Implement serde_with::SerializeAs and serde_with ::DeserializeAs for ArrayVec Sep 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant