rtic/dev/api/fugit/index.html
2024-10-24 05:57:30 +00:00

40 lines
No EOL
17 KiB
HTML

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="`fugit` provides a comprehensive library of `Duration` and `Instant` for the handling of time in embedded systems. The library is specifically designed to maximize const-ification which allows for most comparisons and changes of time-base to be made at compile time, rather than run time."><title>fugit - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../static.files/rustdoc-492a78a4a87dcc01.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="fugit" data-themes="" data-resource-suffix="" data-rustdoc-version="1.82.0 (f6e511eec 2024-10-15)" data-channel="1.82.0" data-search-js="search-a99f1315e7cc5121.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../static.files/storage-118b08c4c78b968e.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-921df33f47b8780c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-3b12f09e550e0385.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-2c020d218678b618.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../fugit/index.html">fugit</a><span class="version">0.3.7</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section><ul class="block"><li><a href="#structs">Structs</a></li><li><a href="#traits">Traits</a></li><li><a href="#types">Type Aliases</a></li></ul></section></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Crate <a class="mod" href="#">fugit</a><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><span class="out-of-band"><a class="src" href="../src/fugit/lib.rs.html#1-1348">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>&#x2212;</span>]</button></span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p><code>fugit</code> provides a comprehensive library of <a href="struct.Duration.html" title="struct fugit::Duration"><code>Duration</code></a> and <a href="struct.Instant.html" title="struct fugit::Instant"><code>Instant</code></a> for the handling of
time in embedded systems. The library is specifically designed to maximize const-ification
which allows for most comparisons and changes of time-base to be made at compile time, rather
than run time.</p>
<p>The library is aimed at ease-of-use and performance first.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>fugit::{Duration, ExtU32};
<span class="comment">// Efficient short-hands (`.millis()`, ...)
</span><span class="kw">let </span>d = Duration::&lt;u32, <span class="number">1</span>, <span class="number">1_000</span>&gt;::from_ticks(<span class="number">111</span>);
<span class="kw">let </span>sum1 = d + <span class="number">300</span>.millis();
<span class="comment">// ^^^ Compile time move of base, only a sum is needed and no change of base
// -----------------------
// Best effort for fixed types
</span><span class="kw">fn </span>bar(d1: Duration&lt;u32, <span class="number">1</span>, <span class="number">1_000</span>&gt;, d2: Duration&lt;u32, <span class="number">1</span>, <span class="number">1_000_000</span>&gt;) {
<span class="kw">let </span>sum = d1 + d2.convert();
<span class="comment">// ^^^^^^^ Run time move of base, will use a `mul` and `div` instruction (Cortex-M3+) to
// perform the move of base.
// The `.convert()` explicitly signals the move of base.
</span><span class="kw">let </span>ops = d1 &gt; d2;
<span class="comment">// ^^^^^^^ Run time comparison of different base, will use 2 `mul` instructions
// (Cortex-M3+) to perform the comparison.
</span>}
<span class="kw">fn </span>baz(d1: Duration&lt;u64, <span class="number">1</span>, <span class="number">1_000</span>&gt;, d2: Duration&lt;u64, <span class="number">1</span>, <span class="number">1_000_000</span>&gt;) {
<span class="kw">let </span>sum = d1 + d2.convert();
<span class="comment">// ^^^^^^^ Run time move of base, will use a `mul` insruction and `div`
// soft-impl (Cortex-M3+) to perform the move of base.
// The `.convert()` explicitly signals the move of base.
</span><span class="kw">let </span>ops = d1 &gt; d2;
<span class="comment">// ^^^^^^^ Run time comparison of different base, will use 4 `mul` instructions
// (Cortex-M3+) to perform the comparison.
</span>}</code></pre></div>
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.Duration.html" title="struct fugit::Duration">Duration</a></div><div class="desc docblock-short">Represents a duration of time.</div></li><li><div class="item-name"><a class="struct" href="struct.Instant.html" title="struct fugit::Instant">Instant</a></div><div class="desc docblock-short">Represents an instant in time.</div></li><li><div class="item-name"><a class="struct" href="struct.Rate.html" title="struct fugit::Rate">Rate</a></div><div class="desc docblock-short">Represents a frequency.</div></li></ul><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="trait" href="trait.ExtU32.html" title="trait fugit::ExtU32">ExtU32</a></div><div class="desc docblock-short">Extension trait for simple short-hands for u32 Durations</div></li><li><div class="item-name"><a class="trait" href="trait.ExtU64.html" title="trait fugit::ExtU64">ExtU64</a></div><div class="desc docblock-short">Extension trait for simple short-hands for u64 Durations</div></li><li><div class="item-name"><a class="trait" href="trait.ExtU32Ceil.html" title="trait fugit::ExtU32Ceil">ExtU32<wbr>Ceil</a></div><div class="desc docblock-short">Extension trait for simple short-hands for u32 Durations (ceil rounded)</div></li><li><div class="item-name"><a class="trait" href="trait.ExtU64Ceil.html" title="trait fugit::ExtU64Ceil">ExtU64<wbr>Ceil</a></div><div class="desc docblock-short">Extension trait for simple short-hands for u64 Durations (ceil rounded)</div></li><li><div class="item-name"><a class="trait" href="trait.RateExtU32.html" title="trait fugit::RateExtU32">Rate<wbr>ExtU32</a></div><div class="desc docblock-short">Extension trait for simple short-hands for u32 Rate</div></li><li><div class="item-name"><a class="trait" href="trait.RateExtU64.html" title="trait fugit::RateExtU64">Rate<wbr>ExtU64</a></div><div class="desc docblock-short">Extension trait for simple short-hands for u64 Rate</div></li></ul><h2 id="types" class="section-header">Type Aliases<a href="#types" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="type" href="type.Hertz.html" title="type fugit::Hertz">Hertz</a></div><div class="desc docblock-short">Alias for hertz rate</div></li><li><div class="item-name"><a class="type" href="type.HertzU32.html" title="type fugit::HertzU32">Hertz<wbr>U32</a></div><div class="desc docblock-short">Alias for hertz rate (<code>u32</code> backing storage)</div></li><li><div class="item-name"><a class="type" href="type.HertzU64.html" title="type fugit::HertzU64">Hertz<wbr>U64</a></div><div class="desc docblock-short">Alias for hertz rate (<code>u64</code> backing storage)</div></li><li><div class="item-name"><a class="type" href="type.HoursDuration.html" title="type fugit::HoursDuration">Hours<wbr>Duration</a></div><div class="desc docblock-short">Alias for hours duration</div></li><li><div class="item-name"><a class="type" href="type.HoursDurationU32.html" title="type fugit::HoursDurationU32">Hours<wbr>Duration<wbr>U32</a></div><div class="desc docblock-short">Alias for hours duration (<code>u32</code> backing storage)</div></li><li><div class="item-name"><a class="type" href="type.HoursDurationU64.html" title="type fugit::HoursDurationU64">Hours<wbr>Duration<wbr>U64</a></div><div class="desc docblock-short">Alias for hours duration (<code>u64</code> backing storage)</div></li><li><div class="item-name"><a class="type" href="type.Kilohertz.html" title="type fugit::Kilohertz">Kilohertz</a></div><div class="desc docblock-short">Alias for kilohertz rate</div></li><li><div class="item-name"><a class="type" href="type.KilohertzU32.html" title="type fugit::KilohertzU32">Kilohertz<wbr>U32</a></div><div class="desc docblock-short">Alias for kilohertz rate (<code>u32</code> backing storage)</div></li><li><div class="item-name"><a class="type" href="type.KilohertzU64.html" title="type fugit::KilohertzU64">Kilohertz<wbr>U64</a></div><div class="desc docblock-short">Alias for kilohertz rate (<code>u64</code> backing storage)</div></li><li><div class="item-name"><a class="type" href="type.Megahertz.html" title="type fugit::Megahertz">Megahertz</a></div><div class="desc docblock-short">Alias for megahertz rate</div></li><li><div class="item-name"><a class="type" href="type.MegahertzU32.html" title="type fugit::MegahertzU32">Megahertz<wbr>U32</a></div><div class="desc docblock-short">Alias for megahertz rate (<code>u32</code> backing storage)</div></li><li><div class="item-name"><a class="type" href="type.MegahertzU64.html" title="type fugit::MegahertzU64">Megahertz<wbr>U64</a></div><div class="desc docblock-short">Alias for megahertz rate (<code>u64</code> backing storage)</div></li><li><div class="item-name"><a class="type" href="type.MicrosDuration.html" title="type fugit::MicrosDuration">Micros<wbr>Duration</a></div><div class="desc docblock-short">Alias for microsecond duration</div></li><li><div class="item-name"><a class="type" href="type.MicrosDurationU32.html" title="type fugit::MicrosDurationU32">Micros<wbr>Duration<wbr>U32</a></div><div class="desc docblock-short">Alias for microsecond duration (<code>u32</code> backing storage)</div></li><li><div class="item-name"><a class="type" href="type.MicrosDurationU64.html" title="type fugit::MicrosDurationU64">Micros<wbr>Duration<wbr>U64</a></div><div class="desc docblock-short">Alias for microsecond duration (<code>u64</code> backing storage)</div></li><li><div class="item-name"><a class="type" href="type.MillisDuration.html" title="type fugit::MillisDuration">Millis<wbr>Duration</a></div><div class="desc docblock-short">Alias for millisecond duration</div></li><li><div class="item-name"><a class="type" href="type.MillisDurationU32.html" title="type fugit::MillisDurationU32">Millis<wbr>Duration<wbr>U32</a></div><div class="desc docblock-short">Alias for millisecond duration (<code>u32</code> backing storage)</div></li><li><div class="item-name"><a class="type" href="type.MillisDurationU64.html" title="type fugit::MillisDurationU64">Millis<wbr>Duration<wbr>U64</a></div><div class="desc docblock-short">Alias for millisecond duration (<code>u64</code> backing storage)</div></li><li><div class="item-name"><a class="type" href="type.MinutesDuration.html" title="type fugit::MinutesDuration">Minutes<wbr>Duration</a></div><div class="desc docblock-short">Alias for minutes duration</div></li><li><div class="item-name"><a class="type" href="type.MinutesDurationU32.html" title="type fugit::MinutesDurationU32">Minutes<wbr>Duration<wbr>U32</a></div><div class="desc docblock-short">Alias for minutes duration (<code>u32</code> backing storage)</div></li><li><div class="item-name"><a class="type" href="type.MinutesDurationU64.html" title="type fugit::MinutesDurationU64">Minutes<wbr>Duration<wbr>U64</a></div><div class="desc docblock-short">Alias for minutes duration (<code>u64</code> backing storage)</div></li><li><div class="item-name"><a class="type" href="type.NanosDuration.html" title="type fugit::NanosDuration">Nanos<wbr>Duration</a></div><div class="desc docblock-short">Alias for nanosecond duration</div></li><li><div class="item-name"><a class="type" href="type.NanosDurationU32.html" title="type fugit::NanosDurationU32">Nanos<wbr>Duration<wbr>U32</a></div><div class="desc docblock-short">Alias for nanosecond duration (<code>u32</code> backing storage)</div></li><li><div class="item-name"><a class="type" href="type.NanosDurationU64.html" title="type fugit::NanosDurationU64">Nanos<wbr>Duration<wbr>U64</a></div><div class="desc docblock-short">Alias for nanosecond duration (<code>u64</code> backing storage)</div></li><li><div class="item-name"><a class="type" href="type.SecsDuration.html" title="type fugit::SecsDuration">Secs<wbr>Duration</a></div><div class="desc docblock-short">Alias for second duration</div></li><li><div class="item-name"><a class="type" href="type.SecsDurationU32.html" title="type fugit::SecsDurationU32">Secs<wbr>Duration<wbr>U32</a></div><div class="desc docblock-short">Alias for second duration (<code>u32</code> backing storage)</div></li><li><div class="item-name"><a class="type" href="type.SecsDurationU64.html" title="type fugit::SecsDurationU64">Secs<wbr>Duration<wbr>U64</a></div><div class="desc docblock-short">Alias for second duration (<code>u64</code> backing storage)</div></li><li><div class="item-name"><a class="type" href="type.TimerDuration.html" title="type fugit::TimerDuration">Timer<wbr>Duration</a></div><div class="desc docblock-short">Alias for durations that come from timers with a specific frequency</div></li><li><div class="item-name"><a class="type" href="type.TimerDurationU32.html" title="type fugit::TimerDurationU32">Timer<wbr>Duration<wbr>U32</a></div><div class="desc docblock-short">Alias for durations that come from timers with a specific frequency (<code>u32</code> backing storage)</div></li><li><div class="item-name"><a class="type" href="type.TimerDurationU64.html" title="type fugit::TimerDurationU64">Timer<wbr>Duration<wbr>U64</a></div><div class="desc docblock-short">Alias for durations that come from timers with a specific frequency (<code>u64</code> backing storage)</div></li><li><div class="item-name"><a class="type" href="type.TimerInstant.html" title="type fugit::TimerInstant">Timer<wbr>Instant</a></div><div class="desc docblock-short">Alias for instants that come from timers with a specific frequency</div></li><li><div class="item-name"><a class="type" href="type.TimerInstantU32.html" title="type fugit::TimerInstantU32">Timer<wbr>Instant<wbr>U32</a></div><div class="desc docblock-short">Alias for instants that come from timers with a specific frequency (<code>u32</code> backing storage)</div></li><li><div class="item-name"><a class="type" href="type.TimerInstantU64.html" title="type fugit::TimerInstantU64">Timer<wbr>Instant<wbr>U64</a></div><div class="desc docblock-short">Alias for instants that come from timers with a specific frequency (<code>u64</code> backing storage)</div></li><li><div class="item-name"><a class="type" href="type.TimerRate.html" title="type fugit::TimerRate">Timer<wbr>Rate</a></div><div class="desc docblock-short">Alias for rate that come from timers with a specific frequency</div></li><li><div class="item-name"><a class="type" href="type.TimerRateU32.html" title="type fugit::TimerRateU32">Timer<wbr>Rate<wbr>U32</a></div><div class="desc docblock-short">Alias for rate that come from timers with a specific frequency (<code>u32</code> backing storage)</div></li><li><div class="item-name"><a class="type" href="type.TimerRateU64.html" title="type fugit::TimerRateU64">Timer<wbr>Rate<wbr>U64</a></div><div class="desc docblock-short">Alias for rate that come from timers with a specific frequency (<code>u64</code> backing storage)</div></li></ul></section></div></main></body></html>