mirror of
https://github.com/fafhrd91/actix-web
synced 2025-01-19 22:24:40 +01:00
34 lines
14 KiB
HTML
34 lines
14 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="An extension trait for `std::time::Instant` that adds methods for `time::Duration`s."><title>InstantExt in actix_web::cookie::time::ext - 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-dd39b87e5fcfba68.css"><meta name="rustdoc-vars" data-root-path="../../../../" data-static-root-path="../../../../static.files/" data-current-crate="actix_web" data-themes="" data-resource-suffix="" data-rustdoc-version="1.80.0-nightly (bdbbb6c6a 2024-05-26)" data-channel="nightly" data-search-js="search-d52510db62a78183.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../../../../static.files/storage-118b08c4c78b968e.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../../../static.files/main-20a3ad099b048cf2.js"></script><noscript><link rel="stylesheet" href="../../../../static.files/noscript-df360f571f6edeae.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc trait"><!--[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><a class="logo-container" href="../../../../actix_web/index.html"><img src="https://actix.rs/img/logo.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../../../actix_web/index.html"><img src="https://actix.rs/img/logo.png" alt="logo"></a><h2><a href="../../../../actix_web/index.html">actix_web</a><span class="version">4.6.0</span></h2></div><h2 class="location"><a href="#">InstantExt</a></h2><div class="sidebar-elems"><section><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.checked_add_signed">checked_add_signed</a></li><li><a href="#tymethod.checked_sub_signed">checked_sub_signed</a></li><li><a href="#tymethod.signed_duration_since">signed_duration_since</a></li></ul><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.add_signed">add_signed</a></li><li><a href="#method.sub_signed">sub_signed</a></li></ul><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-InstantExt-for-Instant">Instant</a></li></ul><h3><a href="#object-safety">Object Safety</a></h3><h3><a href="#implementors">Implementors</a></h3></section><h2><a href="index.html">In actix_web::cookie::time::ext</a></h2></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>Trait <a href="../../../index.html">actix_web</a>::<wbr><a href="../../index.html">cookie</a>::<wbr><a href="../index.html">time</a>::<wbr><a href="index.html">ext</a>::<wbr><a class="trait" href="#">InstantExt</a><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><span class="out-of-band"><button id="toggle-all-docs" title="collapse all docs">[<span>−</span>]</button></span></div><pre class="rust item-decl"><code>pub trait InstantExt: Sealed {
|
||
// Required methods
|
||
fn <a href="#tymethod.checked_add_signed" class="fn">checked_add_signed</a>(&self, duration: <a class="struct" href="../struct.Duration.html" title="struct actix_web::cookie::time::Duration">Duration</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><Self>;
|
||
<span class="item-spacer"></span> fn <a href="#tymethod.checked_sub_signed" class="fn">checked_sub_signed</a>(&self, duration: <a class="struct" href="../struct.Duration.html" title="struct actix_web::cookie::time::Duration">Duration</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><Self>;
|
||
<span class="item-spacer"></span> fn <a href="#tymethod.signed_duration_since" class="fn">signed_duration_since</a>(&self, earlier: Self) -> <a class="struct" href="../struct.Duration.html" title="struct actix_web::cookie::time::Duration">Duration</a>;
|
||
|
||
// Provided methods
|
||
fn <a href="#method.add_signed" class="fn">add_signed</a>(self, duration: <a class="struct" href="../struct.Duration.html" title="struct actix_web::cookie::time::Duration">Duration</a>) -> Self { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.sub_signed" class="fn">sub_signed</a>(self, duration: <a class="struct" href="../struct.Duration.html" title="struct actix_web::cookie::time::Duration">Duration</a>) -> Self { ... }
|
||
}</code></pre><span class="item-info"><div class="stab portability">Available on <strong>crate feature <code>cookies</code></strong> only.</div></span><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>An extension trait for <a href="https://doc.rust-lang.org/nightly/std/time/struct.Instant.html" title="struct std::time::Instant"><code>std::time::Instant</code></a> that adds methods for
|
||
<a href="../struct.Duration.html" title="struct actix_web::cookie::time::Duration"><code>time::Duration</code></a>s.</p>
|
||
</div></details><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.checked_add_signed" class="method"><h4 class="code-header">fn <a href="#tymethod.checked_add_signed" class="fn">checked_add_signed</a>(&self, duration: <a class="struct" href="../struct.Duration.html" title="struct actix_web::cookie::time::Duration">Duration</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><Self></h4></section></summary><div class="docblock"><p>Returns <code>Some(t)</code> where <code>t</code> is the time <code>self.checked_add_signed(duration)</code> if <code>t</code> can be
|
||
represented as <code>Instant</code> (which means it’s inside the bounds of the underlying data
|
||
structure), <code>None</code> otherwise.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.checked_sub_signed" class="method"><h4 class="code-header">fn <a href="#tymethod.checked_sub_signed" class="fn">checked_sub_signed</a>(&self, duration: <a class="struct" href="../struct.Duration.html" title="struct actix_web::cookie::time::Duration">Duration</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><Self></h4></section></summary><div class="docblock"><p>Returns <code>Some(t)</code> where <code>t</code> is the time <code>self.checked_sub_signed(duration)</code> if <code>t</code> can be
|
||
represented as <code>Instant</code> (which means it’s inside the bounds of the underlying data
|
||
structure), <code>None</code> otherwise.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.signed_duration_since" class="method"><h4 class="code-header">fn <a href="#tymethod.signed_duration_since" class="fn">signed_duration_since</a>(&self, earlier: Self) -> <a class="struct" href="../struct.Duration.html" title="struct actix_web::cookie::time::Duration">Duration</a></h4></section></summary><div class="docblock"><p>Returns the amount of time elapsed from another instant to this one. This will be negative
|
||
if <code>earlier</code> is later than <code>self</code>.</p>
|
||
<h5 id="example"><a class="doc-anchor" href="#example">§</a>Example</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>now = Instant::now();
|
||
sleep(Duration::new(<span class="number">1</span>, <span class="number">0</span>));
|
||
<span class="kw">let </span>new_now = Instant::now();
|
||
<span class="macro">println!</span>(<span class="string">"{:?}"</span>, new_now.signed_duration_since(now)); <span class="comment">// positive
|
||
</span><span class="macro">println!</span>(<span class="string">"{:?}"</span>, now.signed_duration_since(new_now)); <span class="comment">// negative</span></code></pre></div>
|
||
</div></details></div><h2 id="provided-methods" class="section-header">Provided Methods<a href="#provided-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="method.add_signed" class="method"><h4 class="code-header">fn <a href="#method.add_signed" class="fn">add_signed</a>(self, duration: <a class="struct" href="../struct.Duration.html" title="struct actix_web::cookie::time::Duration">Duration</a>) -> Self</h4></section></summary><div class="docblock"><h5 id="panics"><a class="doc-anchor" href="#panics">§</a>Panics</h5>
|
||
<p>This function may panic if the resulting point in time cannot be represented by the
|
||
underlying data structure. See <a href="trait.InstantExt.html#tymethod.checked_add_signed" title="method actix_web::cookie::time::ext::InstantExt::checked_add_signed"><code>InstantExt::checked_add_signed</code></a> for a non-panicking
|
||
version.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.sub_signed" class="method"><h4 class="code-header">fn <a href="#method.sub_signed" class="fn">sub_signed</a>(self, duration: <a class="struct" href="../struct.Duration.html" title="struct actix_web::cookie::time::Duration">Duration</a>) -> Self</h4></section></summary><div class="docblock"><h5 id="panics-1"><a class="doc-anchor" href="#panics-1">§</a>Panics</h5>
|
||
<p>This function may panic if the resulting point in time cannot be represented by the
|
||
underlying data structure. See <a href="trait.InstantExt.html#tymethod.checked_sub_signed" title="method actix_web::cookie::time::ext::InstantExt::checked_sub_signed"><code>InstantExt::checked_sub_signed</code></a> for a non-panicking
|
||
version.</p>
|
||
</div></details></div><h2 id="object-safety" class="section-header">Object Safety<a href="#object-safety" class="anchor">§</a></h2><div class="object-safety-info">This trait is <b>not</b> <a href="https://doc.rust-lang.org/nightly/reference/items/traits.html#object-safety">object safe</a>.</div><h2 id="foreign-impls" class="section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor">§</a></h2><details class="toggle implementors-toggle"><summary><section id="impl-InstantExt-for-Instant" class="impl"><a href="#impl-InstantExt-for-Instant" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.InstantExt.html" title="trait actix_web::cookie::time::ext::InstantExt">InstantExt</a> for <a class="struct" href="https://doc.rust-lang.org/nightly/std/time/struct.Instant.html" title="struct std::time::Instant">Instant</a></h3></section></summary><div class="impl-items"><section id="method.checked_add_signed" class="method trait-impl"><a href="#method.checked_add_signed" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.checked_add_signed" class="fn">checked_add_signed</a>(&self, duration: <a class="struct" href="../struct.Duration.html" title="struct actix_web::cookie::time::Duration">Duration</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/time/struct.Instant.html" title="struct std::time::Instant">Instant</a>></h4></section><section id="method.checked_sub_signed" class="method trait-impl"><a href="#method.checked_sub_signed" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.checked_sub_signed" class="fn">checked_sub_signed</a>(&self, duration: <a class="struct" href="../struct.Duration.html" title="struct actix_web::cookie::time::Duration">Duration</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/time/struct.Instant.html" title="struct std::time::Instant">Instant</a>></h4></section><section id="method.signed_duration_since" class="method trait-impl"><a href="#method.signed_duration_since" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.signed_duration_since" class="fn">signed_duration_since</a>(&self, earlier: <a class="struct" href="https://doc.rust-lang.org/nightly/std/time/struct.Instant.html" title="struct std::time::Instant">Instant</a>) -> <a class="struct" href="../struct.Duration.html" title="struct actix_web::cookie::time::Duration">Duration</a></h4></section></div></details><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"></div><script src="../../../../trait.impl/time/ext/instant/trait.InstantExt.js" data-ignore-extern-crates="std" async></script></section></div></main></body></html> |