Skip to content

Commit

Permalink
Derive defmt::Format on more items
Browse files Browse the repository at this point in the history
  • Loading branch information
sbarral committed Jun 4, 2024
1 parent a929827 commit 8fa57f6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# [Unreleased]

* Add optional support for the `defmt` crate ([#20]).

[#20]: https://github.com/asynchronics/tai-time/pull/20


# 0.3.1 (2024-05-11)

* honor formatter precision specifier (`{:.N}`) for nanosecond display.
* Honor formatter precision specifier (`{:.N}`) for nanosecond display ([#19]).

[#19]: https://github.com/asynchronics/tai-time/pull/19


# 0.3.0 (2024-04-07)
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ in `TaiTime::now`.
`TaiTime` and related error types can be (de)serialized with `serde` by
activating the `serde` feature.

### `defmt` support

Activating the `defmt` feature will derive the
[`defmt::Format`](https://defmt.ferrous-systems.com/format) trait on `TaiTime`
and related error types.

## License

Expand Down
3 changes: 3 additions & 0 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use core::fmt;
/// conversion would cause the result to overflow.
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct OutOfRangeError(pub(crate) ());

impl fmt::Display for OutOfRangeError {
Expand All @@ -22,6 +23,7 @@ impl std::error::Error for OutOfRangeError {}
/// to a timestamp outside the representable range.
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum DateTimeError {
/// The month is not between 1 and 12.
InvalidMonth(u8),
Expand Down Expand Up @@ -66,6 +68,7 @@ impl std::error::Error for DateTimeError {}
/// a timestamp outside the representable range.
#[derive(Debug, PartialEq, Eq, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum ParseDateTimeError {
/// A field value is either not of the expected numeric type or is out of
/// range for the expected numeric type.
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@
//!
//! ### `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.
//! Activating the `defmt` feature will derive the
//! [`defmt::Format`](https://defmt.ferrous-systems.com/format) trait on
//! `TaiTime` and related error types.
//!
//! # Examples
//!
Expand Down

0 comments on commit 8fa57f6

Please sign in to comment.