From c4d25bbcb7bfe180cee25bb918d73c5514285c56 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 3 Jun 2024 16:18:32 +0200 Subject: [PATCH] add optional defmt support --- Cargo.toml | 2 ++ src/lib.rs | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index f526740..600526f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,6 +22,7 @@ keywords = ["date", "time", "monotonic", "tai", "gps"] chrono = { version = "0.4.31", default-features = false, optional = true } serde = { version = "1", default-features = false, features = ["derive"], optional = true } nix = { version = "0.26", default-features = false, features = ["time"], optional = true } +defmt = { version = "0.3", optional = true } [features] default = ["std"] @@ -30,6 +31,7 @@ std = [] # activated since cargo resolver v2 ignores MSRV. chrono = ["dep:chrono"] serde = ["dep:serde"] +defmt = ["dep:defmt"] tai_clock = ["dep:nix"] [package.metadata.docs.rs] diff --git a/src/lib.rs b/src/lib.rs index 1099dfb..06433dc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -82,6 +82,11 @@ //! `TaiTime` and related error types can be (de)serialized with `serde` by //! activating the `serde` feature. //! +//! ### `defmt` support +//! +//! Activating the `defmt` feature will add the +//! [`defmt::Format`](https://defmt.ferrous-systems.com/format) derive on all important structures +//! by this crate. //! //! # Examples //! @@ -332,6 +337,7 @@ pub type Tai1972Time = TaiTime<63_072_000>; /// ``` #[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash, PartialOrd, Ord)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] pub struct TaiTime { /// The number of whole seconds in the future (if positive) or in the past /// (if negative) of 1970-01-01 00:00:00 TAI.