Module serde_with::guide::feature_flags

source ·
Expand description

§Available Feature Flags

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.

  • alloc — Enable support for types from the alloc crate when running in a no_std environment.
  • std (enabled by default) — 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.

§Documentation

The following features enhance the documentation of serde_with.

  • guide — The guide feature enables inclusion of this user guide. The feature only changes the rustdoc output and enables no other effects.

§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.

  • base64 — The feature enables serializing data in base64 format.

  • chrono — Deprecated feature name. Use chrono_0_4 instead.

  • 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.

  • hashbrown_0_14 — 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.

  • hex — The feature enables serializing data in hex format.

    This pulls in hex as a dependency. It enables the alloc feature.

  • indexmap — Deprecated feature name. Use indexmap_1 instead.

  • 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_2 — 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.

  • json — The feature enables JSON conversions from the json module.

    This pulls in serde_json as a dependency. It enables the alloc feature.

  • macros (enabled by default) — 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.

  • schemars_0_8 — 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].

  • time_0_3 — 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.