diff options
| -rw-r--r-- | embassy/src/time/duration.rs | 5 | ||||
| -rw-r--r-- | embassy/src/time/instant.rs | 1 |
2 files changed, 5 insertions, 1 deletions
diff --git a/embassy/src/time/duration.rs b/embassy/src/time/duration.rs index c96007747..474d0621b 100644 --- a/embassy/src/time/duration.rs +++ b/embassy/src/time/duration.rs | |||
| @@ -37,6 +37,7 @@ impl Duration { | |||
| 37 | ticks: secs * TICKS_PER_SECOND, | 37 | ticks: secs * TICKS_PER_SECOND, |
| 38 | } | 38 | } |
| 39 | } | 39 | } |
| 40 | |||
| 40 | /// Creates a duration from the specified number of milliseconds | 41 | /// Creates a duration from the specified number of milliseconds |
| 41 | pub const fn from_millis(millis: u64) -> Duration { | 42 | pub const fn from_millis(millis: u64) -> Duration { |
| 42 | Duration { | 43 | Duration { |
| @@ -61,19 +62,21 @@ impl Duration { | |||
| 61 | .checked_add(rhs.ticks) | 62 | .checked_add(rhs.ticks) |
| 62 | .map(|ticks| Duration { ticks }) | 63 | .map(|ticks| Duration { ticks }) |
| 63 | } | 64 | } |
| 65 | |||
| 64 | /// Subtracts one Duration to another, returning a new Duration or None in the event of an overflow. | 66 | /// Subtracts one Duration to another, returning a new Duration or None in the event of an overflow. |
| 65 | pub fn checked_sub(self, rhs: Duration) -> Option<Duration> { | 67 | pub fn checked_sub(self, rhs: Duration) -> Option<Duration> { |
| 66 | self.ticks | 68 | self.ticks |
| 67 | .checked_sub(rhs.ticks) | 69 | .checked_sub(rhs.ticks) |
| 68 | .map(|ticks| Duration { ticks }) | 70 | .map(|ticks| Duration { ticks }) |
| 69 | } | 71 | } |
| 70 | /// Multiplies one Duration to another, returning a new Duration or None in the event of an overflow. | ||
| 71 | 72 | ||
| 73 | /// Multiplies one Duration to another, returning a new Duration or None in the event of an overflow. | ||
| 72 | pub fn checked_mul(self, rhs: u32) -> Option<Duration> { | 74 | pub fn checked_mul(self, rhs: u32) -> Option<Duration> { |
| 73 | self.ticks | 75 | self.ticks |
| 74 | .checked_mul(rhs as _) | 76 | .checked_mul(rhs as _) |
| 75 | .map(|ticks| Duration { ticks }) | 77 | .map(|ticks| Duration { ticks }) |
| 76 | } | 78 | } |
| 79 | |||
| 77 | /// Divides one Duration against another, returning a new Duration or None in the event of an overflow. | 80 | /// Divides one Duration against another, returning a new Duration or None in the event of an overflow. |
| 78 | pub fn checked_div(self, rhs: u32) -> Option<Duration> { | 81 | pub fn checked_div(self, rhs: u32) -> Option<Duration> { |
| 79 | self.ticks | 82 | self.ticks |
diff --git a/embassy/src/time/instant.rs b/embassy/src/time/instant.rs index 9a544fc46..61a61defe 100644 --- a/embassy/src/time/instant.rs +++ b/embassy/src/time/instant.rs | |||
| @@ -31,6 +31,7 @@ impl Instant { | |||
| 31 | ticks: millis * TICKS_PER_SECOND as u64 / 1000, | 31 | ticks: millis * TICKS_PER_SECOND as u64 / 1000, |
| 32 | } | 32 | } |
| 33 | } | 33 | } |
| 34 | |||
| 34 | /// Instant representing seconds since MCU start. | 35 | /// Instant representing seconds since MCU start. |
| 35 | pub const fn from_secs(seconds: u64) -> Self { | 36 | pub const fn from_secs(seconds: u64) -> Self { |
| 36 | Self { | 37 | Self { |
