serde_with 3.11.0

Custom de/serialization functions for Rust's serde
Documentation
lints.workspace = true

[package]
authors = [
    "Jonas Bushart",
    # For creation of the SerializeAs and DeserializeAs traits.
    "Marcin Kaźmierczak",
]
name = "serde_with"

categories = ["encoding", "no-std", "no-std::no-alloc"]
description = "Custom de/serialization functions for Rust's serde"
documentation = "https://docs.rs/serde_with/"
keywords = ["serde", "utilities", "serialization", "deserialization"]

edition.workspace = true
license.workspace = true
readme.workspace = true
repository.workspace = true
rust-version.workspace = true
version.workspace = true

include = ["src/**/*", "tests/**/*", "LICENSE-*", "README.md", "CHANGELOG.md"]

[badges]
maintenance = {status = "actively-developed"}

# When adding new features update the documentation in feature-flags.md
# The features are documented using https://docs.rs/document-features
# lib.rs has support for generating the documentation from the feature flags.
#   https://users.rust-lang.org/t/new-features-on-lib-rs/98560
[features]
default = ["std", "macros"]

#! `serde_with` is fully `no_std` compatible, by depending on it with `default-features = false`.
#! Support for `alloc` and `std` can be enabled with the respective features.
#! Some features require `alloc` or `std` support and might not work in a `no_std` environment.

## Enable support for types from the `alloc` crate when running in a `no_std` environment.
alloc = ["serde/alloc", "base64?/alloc", "chrono_0_4?/alloc", "hex?/alloc", "serde_json?/alloc", "time_0_3?/alloc"]
## Enables support for various types from the std library.
## This will enable `std` support in all dependencies too.
## The feature enabled by default and also enables `alloc`.
std = ["alloc", "serde/std", "chrono_0_4?/clock", "chrono_0_4?/std", "indexmap_1?/std", "indexmap_2?/std", "time_0_3?/serde-well-known", "time_0_3?/std"]

#! # Documentation
#!
#! The following features enhance the documentation of `serde_with`.

## The `guide` feature enables inclusion of this user guide.
## The feature only changes the rustdoc output and enables no other effects.
guide = ["dep:doc-comment", "dep:document-features", "macros", "std"]

#! # Features
#!
#! The following features enable support for types from other crates or enable additional functionality that requires further dependencies to be pulled in.
#! These features are disabled by default to minimize the number of required dependencies.

## The feature enables serializing data in base64 format.
base64 = ["dep:base64", "alloc"]
## Deprecated feature name. Use `chrono_0_4` instead.
chrono = ["chrono_0_4"]
## The feature enables integration of `chrono` v0.4 specific conversions.
## This includes support for the timestamp and duration types.
## More features are available in combination with `alloc` or `std`.
## The legacy feature name `chrono` is still available for v1 compatibility.
##
## This pulls in `chrono` v0.4 as a dependency.
chrono_0_4 = ["dep:chrono_0_4"]
## The feature enables `hashbrown::{HashMap, HashSet}` as supported containers.
##
## This pulls in `hashbrown` v0.14 as a dependency.
## It enables the `alloc` feature.
## Some functionality is only available when `std` is enabled too.
hashbrown_0_14 = ["dep:hashbrown_0_14", "alloc"]
## The feature enables `hashbrown::{HashMap, HashSet}` as supported containers.
##
## This pulls in `hashbrown` v0.15 as a dependency.
## It enables the `alloc` feature.
## Some functionality is only available when `std` is enabled too.
hashbrown_0_15 = ["dep:hashbrown_0_15", "alloc"]
## The feature enables serializing data in hex format.
##
## This pulls in `hex` as a dependency.
## It enables the `alloc` feature.
hex = ["dep:hex", "alloc"]
## Deprecated feature name. Use `indexmap_1` instead.
indexmap = ["indexmap_1"]
## The feature enables implementations of `indexmap` v1 specific checks.
## This includes support for checking duplicate keys and duplicate values.
## The legacy feature name `indexmap` is still available for v1 compatibility.
##
## This pulls in `indexmap` v1 as a dependency.
## It enables the `alloc` feature.
## Some functionality is only available when `std` is enabled too.
indexmap_1 = ["dep:indexmap_1", "alloc"]
## The feature enables implementations of `indexmap` v2 specific checks.
## This includes support for checking duplicate keys and duplicate values.
##
## This pulls in `indexmap` v2 as a dependency.
## It enables the `alloc` feature.
## Some functionality is only available when `std` is enabled too.
indexmap_2 = ["dep:indexmap_2", "alloc"]
## The feature enables JSON conversions from the `json` module.
##
## This pulls in `serde_json` as a dependency.
## It enables the `alloc` feature.
json = ["dep:serde_json", "alloc"]
## The feature enables all helper macros and derives.
## It is enabled by default, since the macros provide a usability benefit, especially for `serde_as`.
##
## This pulls in `serde_with_macros` as a dependency.
macros = ["dep:serde_with_macros"]
## This feature enables integration with `schemars` 0.8.
## This makes `#[derive(JsonSchema)]` pick up the correct schema for the type
## used within `#[serde_as(as = ...)]`.
##
## This pulls in `schemars` v0.8 as a dependency. It will also implicitly enable
## the `std` feature as `schemars` is not `#[no_std]`.
schemars_0_8 = ["dep:schemars_0_8", "std", "serde_with_macros?/schemars_0_8"]
## The feature enables integration of `time` v0.3 specific conversions.
## This includes support for the timestamp and duration types.
##
## This pulls in `time` v0.3 as a dependency.
## Some functionality is only available when `alloc` or `std` is enabled too.
time_0_3 = ["dep:time_0_3"]

# When adding new optional dependencies, update the documentation in feature-flags.md
[dependencies]
base64 = {version = "0.22.1", optional = true, default-features = false}
chrono_0_4 = {package = "chrono", version = "0.4.20", optional = true, default-features = false, features = ["serde"]}
doc-comment = {version = "0.3.3", optional = true}
document-features = {version = "0.2.7", optional = true}
hashbrown_0_14 = {package = "hashbrown", version = "0.14.0", optional = true, default-features = false, features = ["serde"]}
hashbrown_0_15 = {package = "hashbrown", version = "0.15.0", optional = true, default-features = false, features = ["serde"]}
hex = {version = "0.4.3", optional = true, default-features = false}
indexmap_1 = {package = "indexmap", version = "1.8", optional = true, default-features = false, features = ["serde-1"]}
indexmap_2 = {package = "indexmap", version = "2.0", optional = true, default-features = false, features = ["serde"]}
schemars_0_8 = {package = "schemars", version = "0.8.16", optional = true, default-features = false}
serde = {version = "1.0.152", default-features = false}
serde_derive = "1.0.152"
serde_json = {version = "1.0.45", optional = true, default-features = false}
serde_with_macros = {path = "../serde_with_macros", version = "=3.11.0", optional = true}
time_0_3 = {package = "time", version = "~0.3.36", optional = true, default-features = false}

[dev-dependencies]
expect-test = "1.5.0"
fnv = "1.0.6"
glob = "0.3.0"
jsonschema = { version = "0.18.0", default-features = false, features = ["resolve-file"] }
mime = "0.3.16"
pretty_assertions = "1.4.0"
regex = {version = "1.11.0", default-features = false, features = ["std"]}
rmp-serde = "1.3.0"
ron = "0.8"
rustversion = "1.0.0"
schemars_0_8 = {package = "schemars", version = "0.8.16"}
serde = {version = "1.0.152", default-features = false, features = ["derive"]}
serde_json = {version = "1.0.25", features = ["preserve_order"]}
serde_test = "1.0.124"
serde_yaml = "0.9.2"
serde-xml-rs = "0.6.0"
version-sync = "0.9.1"

[[test]]
name = "base64"
path = "tests/base64.rs"
required-features = ["base64", "macros"]

[[test]]
name = "chrono_0_4"
path = "tests/chrono_0_4.rs"
required-features = ["chrono_0_4", "macros"]

[[test]]
name = "hex"
path = "tests/hex.rs"
required-features = ["hex", "macros"]

[[test]]
name = "hashbrown_0_14"
path = "tests/hashbrown_0_14.rs"
required-features = ["hashbrown_0_14", "macros"]

[[test]]
name = "hashbrown_0_15"
path = "tests/hashbrown_0_15.rs"
required-features = ["hashbrown_0_15", "macros"]

[[test]]
name = "indexmap_1"
path = "tests/indexmap_1.rs"
required-features = ["indexmap_1", "macros"]

[[test]]
name = "indexmap_2"
path = "tests/indexmap_2.rs"
required-features = ["indexmap_2", "macros"]

[[test]]
name = "json"
path = "tests/json.rs"
required-features = ["json", "macros"]

[[test]]
name = "serde_as"
path = "tests/serde_as/lib.rs"
required-features = ["macros"]

[[test]]
name = "time_0_3"
path = "tests/time_0_3.rs"
required-features = ["macros", "time_0_3"]

[[test]]
name = "derives"
path = "tests/derives/lib.rs"
required-features = ["macros"]

[[test]]
name = "with_prefix"
path = "tests/with_prefix.rs"
required-features = ["macros"]

[[test]]
name = "rust"
path = "tests/rust.rs"
required-features = ["alloc"]

[[test]]
name = "schemars_0_8"
path = "tests/schemars_0_8.rs"
required-features = ["schemars_0_8"]

[package.metadata.docs.rs]
all-features = true
rustdoc-args = [
    # Enable doc_cfg showing the required features.
    "--cfg=docsrs",
    # Generate links to definition in rustdoc source code pages
    # https://github.com/rust-lang/rust/pull/84176
    "-Zunstable-options", "--generate-link-to-definition"
]

[package.metadata.release]
pre-release-replacements = [
    {file = "CHANGELOG.md", search = "\\[Unreleased\\]", replace = "[Unreleased]\n\n## [{{version}}] - {{date}}"},
    {file = "src/lib.rs", search = "https://docs\\.rs/serde_with/[\\d.]+/", replace = "https://docs.rs/serde_with/{{version}}/"},
    {file = "README.md", search = "https://docs\\.rs/serde_with/[\\d.]+/", replace = "https://docs.rs/serde_with/{{version}}/"},
]
tag = true
tag-message = "{{crate_name}} v{{version}}"
tag-name = "v{{version}}"