200 lines
No EOL
22 KiB
HTML
200 lines
No EOL
22 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="API documentation for the Rust `SystemTime` struct in crate `bitflags`.">
|
||
<meta name="keywords" content="rust, rustlang, rust-lang, SystemTime">
|
||
|
||
<title>bitflags::__core::time::SystemTime - Rust</title>
|
||
|
||
<link rel="stylesheet" type="text/css" href="../../../rustdoc.css">
|
||
<link rel="stylesheet" type="text/css" href="../../../main.css">
|
||
|
||
|
||
|
||
|
||
</head>
|
||
<body class="rustdoc">
|
||
<!--[if lte IE 8]>
|
||
<div class="warning">
|
||
This old browser is unsupported and will most likely display funky
|
||
things.
|
||
</div>
|
||
<![endif]-->
|
||
|
||
|
||
|
||
<nav class="sidebar">
|
||
|
||
<p class='location'><a href='../../index.html'>bitflags</a>::<wbr><a href='../index.html'>__core</a>::<wbr><a href='index.html'>time</a></p><script>window.sidebarCurrent = {name: 'SystemTime', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></script>
|
||
</nav>
|
||
|
||
<nav class="sub">
|
||
<form class="search-form js-only">
|
||
<div class="search-container">
|
||
<input class="search-input" name="search"
|
||
autocomplete="off"
|
||
placeholder="Click or press ‘S’ to search, ‘?’ for more options…"
|
||
type="search">
|
||
</div>
|
||
</form>
|
||
</nav>
|
||
|
||
<section id='main' class="content struct">
|
||
<h1 class='fqn'><span class='in-band'>Struct <a href='../../index.html'>bitflags</a>::<wbr><a href='../index.html'>__core</a>::<wbr><a href='index.html'>time</a>::<wbr><a class='struct' href=''>SystemTime</a></span><span class='out-of-band'><span id='render-detail'>
|
||
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
|
||
[<span class='inner'>−</span>]
|
||
</a>
|
||
</span><a id='src-10674' class='srclink' href='https://doc.rust-lang.org/nightly/std/time/struct.SystemTime.html?gotosrc=10674' title='goto source code'>[src]</a></span></h1>
|
||
<pre class='rust struct'>pub struct SystemTime(_);</pre><span class="since">1.8.0</span><div class='docblock'><p>A measurement of the system clock, useful for talking to
|
||
external entities like the file system or other processes.</p>
|
||
|
||
<p>Distinct from the <code>Instant</code> type, this time measurement <strong>is not
|
||
monotonic</strong>. This means that you can save a file to the file system, then
|
||
save another file to the file system, <strong>and the second file has a
|
||
<code>SystemTime</code> measurement earlier than the second</strong>. In other words, an
|
||
operation that happens after another operation in real time may have an
|
||
earlier <code>SystemTime</code>!</p>
|
||
|
||
<p>Consequently, comparing two <code>SystemTime</code> instances to learn about the
|
||
duration between them returns a <code>Result</code> instead of an infallible <code>Duration</code>
|
||
to indicate that this sort of time drift may happen and needs to be handled.</p>
|
||
|
||
<p>Although a <code>SystemTime</code> cannot be directly inspected, the <code>UNIX_EPOCH</code>
|
||
constant is provided in this module as an anchor in time to learn
|
||
information about a <code>SystemTime</code>. By calculating the duration from this
|
||
fixed point in time, a <code>SystemTime</code> can be converted to a human-readable time,
|
||
or perhaps some other string representation.</p>
|
||
|
||
<p>Example:</p>
|
||
|
||
<pre class='rust rust-example-rendered'>
|
||
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>time</span>::{<span class='ident'>Duration</span>, <span class='ident'>SystemTime</span>};
|
||
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>thread</span>::<span class='ident'>sleep</span>;
|
||
|
||
<span class='kw'>fn</span> <span class='ident'>main</span>() {
|
||
<span class='kw'>let</span> <span class='ident'>now</span> <span class='op'>=</span> <span class='ident'>SystemTime</span>::<span class='ident'>now</span>();
|
||
|
||
<span class='comment'>// we sleep for 2 seconds</span>
|
||
<span class='ident'>sleep</span>(<span class='ident'>Duration</span>::<span class='ident'>new</span>(<span class='number'>2</span>, <span class='number'>0</span>));
|
||
<span class='kw'>match</span> <span class='ident'>now</span>.<span class='ident'>elapsed</span>() {
|
||
<span class='prelude-val'>Ok</span>(<span class='ident'>elapsed</span>) <span class='op'>=></span> {
|
||
<span class='comment'>// it prints '2'</span>
|
||
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"{}"</span>, <span class='ident'>elapsed</span>.<span class='ident'>as_secs</span>());
|
||
}
|
||
<span class='prelude-val'>Err</span>(<span class='ident'>e</span>) <span class='op'>=></span> {
|
||
<span class='comment'>// an error occured!</span>
|
||
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"Error: {:?}"</span>, <span class='ident'>e</span>);
|
||
}
|
||
}
|
||
}</pre>
|
||
</div><h2 id='methods'>Methods</h2><h3 class='impl'><code>impl <a class='struct' href='../../../bitflags/__core/time/struct.SystemTime.html' title='bitflags::__core::time::SystemTime'>SystemTime</a></code></h3><div class='impl-items'><h4 id='method.now' class='method'><code>fn <a href='#method.now' class='fnname'>now</a>() -> <a class='struct' href='../../../bitflags/__core/time/struct.SystemTime.html' title='bitflags::__core::time::SystemTime'>SystemTime</a></code></h4>
|
||
<div class='docblock'><p>Returns the system time corresponding to "now".</p>
|
||
</div><h4 id='method.duration_since' class='method'><code>fn <a href='#method.duration_since' class='fnname'>duration_since</a>(&self, earlier: <a class='struct' href='../../../bitflags/__core/time/struct.SystemTime.html' title='bitflags::__core::time::SystemTime'>SystemTime</a>) -> <a class='enum' href='../../../bitflags/__core/result/enum.Result.html' title='bitflags::__core::result::Result'>Result</a><<a class='struct' href='../../../bitflags/__core/time/struct.Duration.html' title='bitflags::__core::time::Duration'>Duration</a>, <a class='struct' href='../../../bitflags/__core/time/struct.SystemTimeError.html' title='bitflags::__core::time::SystemTimeError'>SystemTimeError</a>></code></h4>
|
||
<div class='docblock'><p>Returns the amount of time elapsed from an earlier point in time.</p>
|
||
|
||
<p>This function may fail because measurements taken earlier are not
|
||
guaranteed to always be before later measurements (due to anomalies such
|
||
as the system clock being adjusted either forwards or backwards).</p>
|
||
|
||
<p>If successful, <code>Ok(Duration)</code> is returned where the duration represents
|
||
the amount of time elapsed from the specified measurement to this one.</p>
|
||
|
||
<p>Returns an <code>Err</code> if <code>earlier</code> is later than <code>self</code>, and the error
|
||
contains how far from <code>self</code> the time is.</p>
|
||
</div><h4 id='method.duration_from_earlier' class='method'><code>fn <a href='#method.duration_from_earlier' class='fnname'>duration_from_earlier</a>(&self, earlier: <a class='struct' href='../../../bitflags/__core/time/struct.SystemTime.html' title='bitflags::__core::time::SystemTime'>SystemTime</a>) -> <a class='enum' href='../../../bitflags/__core/result/enum.Result.html' title='bitflags::__core::result::Result'>Result</a><<a class='struct' href='../../../bitflags/__core/time/struct.Duration.html' title='bitflags::__core::time::Duration'>Duration</a>, <a class='struct' href='../../../bitflags/__core/time/struct.SystemTimeError.html' title='bitflags::__core::time::SystemTimeError'>SystemTimeError</a>></code></h4>
|
||
<div class='stability'><em class='stab deprecated'>Deprecated since 1.8.0<p>: renamed to duration_since</p>
|
||
</em></div><div class='stability'><em class='stab unstable'>Unstable (<code>time2_old</code>)<p>: renamed to duration_since</p>
|
||
</em></div><div class='docblock'><p>Deprecated, renamed to <code>duration_since</code></p>
|
||
</div><h4 id='method.elapsed' class='method'><code>fn <a href='#method.elapsed' class='fnname'>elapsed</a>(&self) -> <a class='enum' href='../../../bitflags/__core/result/enum.Result.html' title='bitflags::__core::result::Result'>Result</a><<a class='struct' href='../../../bitflags/__core/time/struct.Duration.html' title='bitflags::__core::time::Duration'>Duration</a>, <a class='struct' href='../../../bitflags/__core/time/struct.SystemTimeError.html' title='bitflags::__core::time::SystemTimeError'>SystemTimeError</a>></code></h4>
|
||
<div class='docblock'><p>Returns the amount of time elapsed since this system time was created.</p>
|
||
|
||
<p>This function may fail as the underlying system clock is susceptible to
|
||
drift and updates (e.g. the system clock could go backwards), so this
|
||
function may not always succeed. If successful, <code>Ok(duration)</code> is
|
||
returned where the duration represents the amount of time elapsed from
|
||
this time measurement to the current time.</p>
|
||
|
||
<p>Returns an <code>Err</code> if <code>self</code> is later than the current system time, and
|
||
the error contains how far from the current system time <code>self</code> is.</p>
|
||
</div></div><h2 id='implementations'>Trait Implementations</h2><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/ops/trait.Add.html' title='bitflags::__core::ops::Add'>Add</a><<a class='struct' href='../../../bitflags/__core/time/struct.Duration.html' title='bitflags::__core::time::Duration'>Duration</a>> for <a class='struct' href='../../../bitflags/__core/time/struct.SystemTime.html' title='bitflags::__core::time::SystemTime'>SystemTime</a></code></h3><div class='impl-items'><h4 id='associatedtype.Output' class='type'><code>type <a href='../../../bitflags/__core/ops/trait.Add.html#associatedtype.Output' class='type'>Output</a> = <a class='struct' href='../../../bitflags/__core/time/struct.SystemTime.html' title='bitflags::__core::time::SystemTime'>SystemTime</a></code></h4>
|
||
<h4 id='method.add' class='method'><code>fn <a href='../../../bitflags/__core/ops/trait.Add.html#tymethod.add' class='fnname'>add</a>(self, dur: <a class='struct' href='../../../bitflags/__core/time/struct.Duration.html' title='bitflags::__core::time::Duration'>Duration</a>) -> <a class='struct' href='../../../bitflags/__core/time/struct.SystemTime.html' title='bitflags::__core::time::SystemTime'>SystemTime</a></code></h4>
|
||
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/ops/trait.AddAssign.html' title='bitflags::__core::ops::AddAssign'>AddAssign</a><<a class='struct' href='../../../bitflags/__core/time/struct.Duration.html' title='bitflags::__core::time::Duration'>Duration</a>> for <a class='struct' href='../../../bitflags/__core/time/struct.SystemTime.html' title='bitflags::__core::time::SystemTime'>SystemTime</a></code><span class="since">1.9.0</span></h3><div class='impl-items'><h4 id='method.add_assign' class='method'><code>fn <a href='../../../bitflags/__core/ops/trait.AddAssign.html#tymethod.add_assign' class='fnname'>add_assign</a>(&mut self, other: <a class='struct' href='../../../bitflags/__core/time/struct.Duration.html' title='bitflags::__core::time::Duration'>Duration</a>)</code></h4>
|
||
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/ops/trait.Sub.html' title='bitflags::__core::ops::Sub'>Sub</a><<a class='struct' href='../../../bitflags/__core/time/struct.Duration.html' title='bitflags::__core::time::Duration'>Duration</a>> for <a class='struct' href='../../../bitflags/__core/time/struct.SystemTime.html' title='bitflags::__core::time::SystemTime'>SystemTime</a></code></h3><div class='impl-items'><h4 id='associatedtype.Output-1' class='type'><code>type <a href='../../../bitflags/__core/ops/trait.Sub.html#associatedtype.Output' class='type'>Output</a> = <a class='struct' href='../../../bitflags/__core/time/struct.SystemTime.html' title='bitflags::__core::time::SystemTime'>SystemTime</a></code></h4>
|
||
<h4 id='method.sub' class='method'><code>fn <a href='../../../bitflags/__core/ops/trait.Sub.html#tymethod.sub' class='fnname'>sub</a>(self, dur: <a class='struct' href='../../../bitflags/__core/time/struct.Duration.html' title='bitflags::__core::time::Duration'>Duration</a>) -> <a class='struct' href='../../../bitflags/__core/time/struct.SystemTime.html' title='bitflags::__core::time::SystemTime'>SystemTime</a></code></h4>
|
||
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/ops/trait.SubAssign.html' title='bitflags::__core::ops::SubAssign'>SubAssign</a><<a class='struct' href='../../../bitflags/__core/time/struct.Duration.html' title='bitflags::__core::time::Duration'>Duration</a>> for <a class='struct' href='../../../bitflags/__core/time/struct.SystemTime.html' title='bitflags::__core::time::SystemTime'>SystemTime</a></code><span class="since">1.9.0</span></h3><div class='impl-items'><h4 id='method.sub_assign' class='method'><code>fn <a href='../../../bitflags/__core/ops/trait.SubAssign.html#tymethod.sub_assign' class='fnname'>sub_assign</a>(&mut self, other: <a class='struct' href='../../../bitflags/__core/time/struct.Duration.html' title='bitflags::__core::time::Duration'>Duration</a>)</code></h4>
|
||
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/fmt/trait.Debug.html' title='bitflags::__core::fmt::Debug'>Debug</a> for <a class='struct' href='../../../bitflags/__core/time/struct.SystemTime.html' title='bitflags::__core::time::SystemTime'>SystemTime</a></code></h3><div class='impl-items'><h4 id='method.fmt' class='method'><code>fn <a href='../../../bitflags/__core/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&self, f: &mut <a class='struct' href='../../../bitflags/__core/fmt/struct.Formatter.html' title='bitflags::__core::fmt::Formatter'>Formatter</a>) -> <a class='enum' href='../../../bitflags/__core/result/enum.Result.html' title='bitflags::__core::result::Result'>Result</a><<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.tuple.html'>()</a>, <a class='struct' href='../../../bitflags/__core/fmt/struct.Error.html' title='bitflags::__core::fmt::Error'>Error</a>></code></h4>
|
||
</div><h3 id='derived_implementations'>Derived Implementations </h3><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/cmp/trait.Ord.html' title='bitflags::__core::cmp::Ord'>Ord</a> for <a class='struct' href='../../../bitflags/__core/time/struct.SystemTime.html' title='bitflags::__core::time::SystemTime'>SystemTime</a></code></h3><div class='impl-items'><h4 id='method.cmp' class='method'><code>fn <a href='../../../bitflags/__core/cmp/trait.Ord.html#tymethod.cmp' class='fnname'>cmp</a>(&self, __arg_0: &<a class='struct' href='../../../bitflags/__core/time/struct.SystemTime.html' title='bitflags::__core::time::SystemTime'>SystemTime</a>) -> <a class='enum' href='../../../bitflags/__core/cmp/enum.Ordering.html' title='bitflags::__core::cmp::Ordering'>Ordering</a></code></h4>
|
||
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/cmp/trait.PartialOrd.html' title='bitflags::__core::cmp::PartialOrd'>PartialOrd</a><<a class='struct' href='../../../bitflags/__core/time/struct.SystemTime.html' title='bitflags::__core::time::SystemTime'>SystemTime</a>> for <a class='struct' href='../../../bitflags/__core/time/struct.SystemTime.html' title='bitflags::__core::time::SystemTime'>SystemTime</a></code></h3><div class='impl-items'><h4 id='method.partial_cmp' class='method'><code>fn <a href='../../../bitflags/__core/cmp/trait.PartialOrd.html#tymethod.partial_cmp' class='fnname'>partial_cmp</a>(&self, __arg_0: &<a class='struct' href='../../../bitflags/__core/time/struct.SystemTime.html' title='bitflags::__core::time::SystemTime'>SystemTime</a>) -> <a class='enum' href='../../../bitflags/__core/option/enum.Option.html' title='bitflags::__core::option::Option'>Option</a><<a class='enum' href='../../../bitflags/__core/cmp/enum.Ordering.html' title='bitflags::__core::cmp::Ordering'>Ordering</a>></code></h4>
|
||
<h4 id='method.lt' class='method'><code>fn <a href='../../../bitflags/__core/cmp/trait.PartialOrd.html#method.lt' class='fnname'>lt</a>(&self, __arg_0: &<a class='struct' href='../../../bitflags/__core/time/struct.SystemTime.html' title='bitflags::__core::time::SystemTime'>SystemTime</a>) -> <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.bool.html'>bool</a></code></h4>
|
||
<h4 id='method.le' class='method'><code>fn <a href='../../../bitflags/__core/cmp/trait.PartialOrd.html#method.le' class='fnname'>le</a>(&self, __arg_0: &<a class='struct' href='../../../bitflags/__core/time/struct.SystemTime.html' title='bitflags::__core::time::SystemTime'>SystemTime</a>) -> <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.bool.html'>bool</a></code></h4>
|
||
<h4 id='method.gt' class='method'><code>fn <a href='../../../bitflags/__core/cmp/trait.PartialOrd.html#method.gt' class='fnname'>gt</a>(&self, __arg_0: &<a class='struct' href='../../../bitflags/__core/time/struct.SystemTime.html' title='bitflags::__core::time::SystemTime'>SystemTime</a>) -> <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.bool.html'>bool</a></code></h4>
|
||
<h4 id='method.ge' class='method'><code>fn <a href='../../../bitflags/__core/cmp/trait.PartialOrd.html#method.ge' class='fnname'>ge</a>(&self, __arg_0: &<a class='struct' href='../../../bitflags/__core/time/struct.SystemTime.html' title='bitflags::__core::time::SystemTime'>SystemTime</a>) -> <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.bool.html'>bool</a></code></h4>
|
||
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/cmp/trait.Eq.html' title='bitflags::__core::cmp::Eq'>Eq</a> for <a class='struct' href='../../../bitflags/__core/time/struct.SystemTime.html' title='bitflags::__core::time::SystemTime'>SystemTime</a></code></h3><div class='impl-items'></div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/cmp/trait.PartialEq.html' title='bitflags::__core::cmp::PartialEq'>PartialEq</a><<a class='struct' href='../../../bitflags/__core/time/struct.SystemTime.html' title='bitflags::__core::time::SystemTime'>SystemTime</a>> for <a class='struct' href='../../../bitflags/__core/time/struct.SystemTime.html' title='bitflags::__core::time::SystemTime'>SystemTime</a></code></h3><div class='impl-items'><h4 id='method.eq' class='method'><code>fn <a href='../../../bitflags/__core/cmp/trait.PartialEq.html#tymethod.eq' class='fnname'>eq</a>(&self, __arg_0: &<a class='struct' href='../../../bitflags/__core/time/struct.SystemTime.html' title='bitflags::__core::time::SystemTime'>SystemTime</a>) -> <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.bool.html'>bool</a></code></h4>
|
||
<h4 id='method.ne' class='method'><code>fn <a href='../../../bitflags/__core/cmp/trait.PartialEq.html#method.ne' class='fnname'>ne</a>(&self, __arg_0: &<a class='struct' href='../../../bitflags/__core/time/struct.SystemTime.html' title='bitflags::__core::time::SystemTime'>SystemTime</a>) -> <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.bool.html'>bool</a></code></h4>
|
||
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/clone/trait.Clone.html' title='bitflags::__core::clone::Clone'>Clone</a> for <a class='struct' href='../../../bitflags/__core/time/struct.SystemTime.html' title='bitflags::__core::time::SystemTime'>SystemTime</a></code></h3><div class='impl-items'><h4 id='method.clone' class='method'><code>fn <a href='../../../bitflags/__core/clone/trait.Clone.html#tymethod.clone' class='fnname'>clone</a>(&self) -> <a class='struct' href='../../../bitflags/__core/time/struct.SystemTime.html' title='bitflags::__core::time::SystemTime'>SystemTime</a></code></h4>
|
||
<h4 id='method.clone_from' class='method'><code>fn <a href='../../../bitflags/__core/clone/trait.Clone.html#method.clone_from' class='fnname'>clone_from</a>(&mut self, source: &Self)</code><span class="since">1.0.0</span></h4>
|
||
</div><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/marker/trait.Copy.html' title='bitflags::__core::marker::Copy'>Copy</a> for <a class='struct' href='../../../bitflags/__core/time/struct.SystemTime.html' title='bitflags::__core::time::SystemTime'>SystemTime</a></code></h3><div class='impl-items'></div></section>
|
||
<section id='search' class="content hidden"></section>
|
||
|
||
<section class="footer"></section>
|
||
|
||
<aside id="help" class="hidden">
|
||
<div>
|
||
<h1 class="hidden">Help</h1>
|
||
|
||
<div class="shortcuts">
|
||
<h2>Keyboard Shortcuts</h2>
|
||
|
||
<dl>
|
||
<dt>?</dt>
|
||
<dd>Show this help dialog</dd>
|
||
<dt>S</dt>
|
||
<dd>Focus the search field</dd>
|
||
<dt>⇤</dt>
|
||
<dd>Move up in search results</dd>
|
||
<dt>⇥</dt>
|
||
<dd>Move down in search results</dd>
|
||
<dt>⏎</dt>
|
||
<dd>Go to active search result</dd>
|
||
</dl>
|
||
</div>
|
||
|
||
<div class="infos">
|
||
<h2>Search Tricks</h2>
|
||
|
||
<p>
|
||
Prefix searches with a type followed by a colon (e.g.
|
||
<code>fn:</code>) to restrict the search to a given type.
|
||
</p>
|
||
|
||
<p>
|
||
Accepted types are: <code>fn</code>, <code>mod</code>,
|
||
<code>struct</code>, <code>enum</code>,
|
||
<code>trait</code>, <code>type</code>, <code>macro</code>,
|
||
and <code>const</code>.
|
||
</p>
|
||
|
||
<p>
|
||
Search functions by type signature (e.g.
|
||
<code>vec -> usize</code> or <code>* -> vec</code>)
|
||
</p>
|
||
</div>
|
||
</div>
|
||
</aside>
|
||
|
||
|
||
|
||
<script>
|
||
window.rootPath = "../../../";
|
||
window.currentCrate = "bitflags";
|
||
window.playgroundUrl = "";
|
||
</script>
|
||
<script src="../../../jquery.js"></script>
|
||
<script src="../../../main.js"></script>
|
||
|
||
<script defer src="../../../search-index.js"></script>
|
||
</body>
|
||
</html> |