Skip to content

Commit

Permalink
Merge #626
Browse files Browse the repository at this point in the history
626: Clarify serialization behavior of Duration* and Timestamp* types r=jonasbb a=jonasbb

Closes #625

bors r+

Co-authored-by: Jonas Bushart <[email protected]>
  • Loading branch information
bors[bot] and jonasbb authored Jul 31, 2023
2 parents 20fae7c + 08ca335 commit b81abda
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions serde_with/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,7 @@ pub struct BytesOrString;
/// [`formats::Strict`] means that deserialization only supports the type given in `FORMAT`, e.g., if `FORMAT` is `u64` deserialization from a `f64` will error.
/// [`formats::Flexible`] means that deserialization will perform a best effort to extract the correct duration and allows deserialization from any type.
/// For example, deserializing `DurationSeconds<f64, Flexible>` will discard any subsecond precision during deserialization from `f64` and will parse a `String` as an integer number.
/// Serialization of integers will round the duration to the nearest value.
///
/// This type also supports [`chrono::Duration`] with the `chrono_0_4`-[feature flag].
/// This type also supports [`time::Duration`][::time_0_3::Duration] with the `time_0_3`-[feature flag].
Expand Down Expand Up @@ -937,6 +938,7 @@ pub struct DurationSeconds<
/// De/serialize durations as number of seconds with subsecond precision.
/// Subsecond precision is *only* supported for [`DurationSecondsWithFrac`], but not for [`DurationSeconds`].
/// You can configure the serialization format between integers, floats, and stringified numbers with the `FORMAT` specifier and configure the deserialization with the `STRICTNESS` specifier.
/// Serialization of integers will round the duration to the nearest value.
///
/// The `STRICTNESS` specifier can either be [`formats::Strict`] or [`formats::Flexible`] and defaults to [`formats::Strict`].
/// [`formats::Strict`] means that deserialization only supports the type given in `FORMAT`, e.g., if `FORMAT` is `u64` deserialization from a `f64` will error.
Expand Down Expand Up @@ -1116,6 +1118,7 @@ pub struct DurationNanoSecondsWithFrac<
/// De/serialize timestamps as seconds since the UNIX epoch.
/// Subsecond precision is *only* supported for [`TimestampSecondsWithFrac`], but not for [`TimestampSeconds`].
/// You can configure the serialization format between integers, floats, and stringified numbers with the `FORMAT` specifier and configure the deserialization with the `STRICTNESS` specifier.
/// Serialization of integers will round the timestamp to the nearest value.
///
/// The `STRICTNESS` specifier can either be [`formats::Strict`] or [`formats::Flexible`] and defaults to [`formats::Strict`].
/// [`formats::Strict`] means that deserialization only supports the type given in `FORMAT`, e.g., if `FORMAT` is `i64` deserialization from a `f64` will error.
Expand Down Expand Up @@ -1269,6 +1272,7 @@ pub struct TimestampSeconds<
/// De/serialize timestamps as seconds since the UNIX epoch.
/// Subsecond precision is *only* supported for [`TimestampSecondsWithFrac`], but not for [`TimestampSeconds`].
/// You can configure the serialization format between integers, floats, and stringified numbers with the `FORMAT` specifier and configure the deserialization with the `STRICTNESS` specifier.
/// Serialization of integers will round the timestamp to the nearest value.
///
/// The `STRICTNESS` specifier can either be [`formats::Strict`] or [`formats::Flexible`] and defaults to [`formats::Strict`].
/// [`formats::Strict`] means that deserialization only supports the type given in `FORMAT`, e.g., if `FORMAT` is `i64` deserialization from a `f64` will error.
Expand Down

0 comments on commit b81abda

Please sign in to comment.