Struct uiuifree_actix_web_util::cookie::Cookie
source · [−]pub struct Cookie<'c> { /* private fields */ }Expand description
Representation of an HTTP cookie.
Constructing a Cookie
To construct a cookie with only a name/value, use Cookie::new():
use cookie::Cookie;
let cookie = Cookie::new("name", "value");
assert_eq!(&cookie.to_string(), "name=value");To construct more elaborate cookies, use Cookie::build() and
CookieBuilder methods:
use cookie::Cookie;
let cookie = Cookie::build("name", "value")
.domain("www.rust-lang.org")
.path("/")
.secure(true)
.http_only(true)
.finish();Implementations
sourceimpl<'c> Cookie<'c>
impl<'c> Cookie<'c>
sourcepub fn new<N, V>(name: N, value: V) -> Cookie<'c> where
N: Into<Cow<'c, str>>,
V: Into<Cow<'c, str>>,
pub fn new<N, V>(name: N, value: V) -> Cookie<'c> where
N: Into<Cow<'c, str>>,
V: Into<Cow<'c, str>>,
Creates a new Cookie with the given name and value.
Example
use cookie::Cookie;
let cookie = Cookie::new("name", "value");
assert_eq!(cookie.name_value(), ("name", "value"));sourcepub fn named<N>(name: N) -> Cookie<'c> where
N: Into<Cow<'c, str>>,
pub fn named<N>(name: N) -> Cookie<'c> where
N: Into<Cow<'c, str>>,
Creates a new Cookie with the given name and an empty value.
Example
use cookie::Cookie;
let cookie = Cookie::named("name");
assert_eq!(cookie.name(), "name");
assert!(cookie.value().is_empty());sourcepub fn build<N, V>(name: N, value: V) -> CookieBuilder<'c> where
N: Into<Cow<'c, str>>,
V: Into<Cow<'c, str>>,
pub fn build<N, V>(name: N, value: V) -> CookieBuilder<'c> where
N: Into<Cow<'c, str>>,
V: Into<Cow<'c, str>>,
Creates a new CookieBuilder instance from the given key and value
strings.
Example
use cookie::Cookie;
let c = Cookie::build("foo", "bar").finish();
assert_eq!(c.name_value(), ("foo", "bar"));sourcepub fn parse<S>(s: S) -> Result<Cookie<'c>, ParseError> where
S: Into<Cow<'c, str>>,
pub fn parse<S>(s: S) -> Result<Cookie<'c>, ParseError> where
S: Into<Cow<'c, str>>,
Parses a Cookie from the given HTTP cookie header value string. Does
not perform any percent-decoding.
Example
use cookie::Cookie;
let c = Cookie::parse("foo=bar%20baz; HttpOnly").unwrap();
assert_eq!(c.name_value(), ("foo", "bar%20baz"));
assert_eq!(c.http_only(), Some(true));sourcepub fn parse_encoded<S>(s: S) -> Result<Cookie<'c>, ParseError> where
S: Into<Cow<'c, str>>,
pub fn parse_encoded<S>(s: S) -> Result<Cookie<'c>, ParseError> where
S: Into<Cow<'c, str>>,
Parses a Cookie from the given HTTP cookie header value string where
the name and value fields are percent-encoded. Percent-decodes the
name/value fields.
Example
use cookie::Cookie;
let c = Cookie::parse_encoded("foo=bar%20baz; HttpOnly").unwrap();
assert_eq!(c.name_value(), ("foo", "bar baz"));
assert_eq!(c.http_only(), Some(true));sourcepub fn into_owned(self) -> Cookie<'static>
pub fn into_owned(self) -> Cookie<'static>
Converts self into a Cookie with a static lifetime with as few
allocations as possible.
Example
use cookie::Cookie;
let c = Cookie::new("a", "b");
let owned_cookie = c.into_owned();
assert_eq!(owned_cookie.name_value(), ("a", "b"));sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Returns the name of self.
Example
use cookie::Cookie;
let c = Cookie::new("name", "value");
assert_eq!(c.name(), "name");sourcepub fn value(&self) -> &str
pub fn value(&self) -> &str
Returns the value of self.
Example
use cookie::Cookie;
let c = Cookie::new("name", "value");
assert_eq!(c.value(), "value");sourcepub fn name_value(&self) -> (&str, &str)
pub fn name_value(&self) -> (&str, &str)
Returns the name and value of self as a tuple of (name, value).
Example
use cookie::Cookie;
let c = Cookie::new("name", "value");
assert_eq!(c.name_value(), ("name", "value"));sourcepub fn http_only(&self) -> Option<bool>
pub fn http_only(&self) -> Option<bool>
Returns whether this cookie was marked HttpOnly or not. Returns
Some(true) when the cookie was explicitly set (manually or parsed) as
HttpOnly, Some(false) when http_only was manually set to false,
and None otherwise.
Example
use cookie::Cookie;
let c = Cookie::parse("name=value; httponly").unwrap();
assert_eq!(c.http_only(), Some(true));
let mut c = Cookie::new("name", "value");
assert_eq!(c.http_only(), None);
let mut c = Cookie::new("name", "value");
assert_eq!(c.http_only(), None);
// An explicitly set "false" value.
c.set_http_only(false);
assert_eq!(c.http_only(), Some(false));
// An explicitly set "true" value.
c.set_http_only(true);
assert_eq!(c.http_only(), Some(true));sourcepub fn secure(&self) -> Option<bool>
pub fn secure(&self) -> Option<bool>
Returns whether this cookie was marked Secure or not. Returns
Some(true) when the cookie was explicitly set (manually or parsed) as
Secure, Some(false) when secure was manually set to false, and
None otherwise.
Example
use cookie::Cookie;
let c = Cookie::parse("name=value; Secure").unwrap();
assert_eq!(c.secure(), Some(true));
let mut c = Cookie::parse("name=value").unwrap();
assert_eq!(c.secure(), None);
let mut c = Cookie::new("name", "value");
assert_eq!(c.secure(), None);
// An explicitly set "false" value.
c.set_secure(false);
assert_eq!(c.secure(), Some(false));
// An explicitly set "true" value.
c.set_secure(true);
assert_eq!(c.secure(), Some(true));sourcepub fn same_site(&self) -> Option<SameSite>
pub fn same_site(&self) -> Option<SameSite>
Returns the SameSite attribute of this cookie if one was specified.
Example
use cookie::{Cookie, SameSite};
let c = Cookie::parse("name=value; SameSite=Lax").unwrap();
assert_eq!(c.same_site(), Some(SameSite::Lax));sourcepub fn max_age(&self) -> Option<Duration>
pub fn max_age(&self) -> Option<Duration>
Returns the specified max-age of the cookie if one was specified.
Example
use cookie::Cookie;
let c = Cookie::parse("name=value").unwrap();
assert_eq!(c.max_age(), None);
let c = Cookie::parse("name=value; Max-Age=3600").unwrap();
assert_eq!(c.max_age().map(|age| age.whole_hours()), Some(1));sourcepub fn path(&self) -> Option<&str>
pub fn path(&self) -> Option<&str>
Returns the Path of the cookie if one was specified.
Example
use cookie::Cookie;
let c = Cookie::parse("name=value").unwrap();
assert_eq!(c.path(), None);
let c = Cookie::parse("name=value; Path=/").unwrap();
assert_eq!(c.path(), Some("/"));
let c = Cookie::parse("name=value; path=/sub").unwrap();
assert_eq!(c.path(), Some("/sub"));sourcepub fn domain(&self) -> Option<&str>
pub fn domain(&self) -> Option<&str>
Returns the Domain of the cookie if one was specified.
Example
use cookie::Cookie;
let c = Cookie::parse("name=value").unwrap();
assert_eq!(c.domain(), None);
let c = Cookie::parse("name=value; Domain=crates.io").unwrap();
assert_eq!(c.domain(), Some("crates.io"));sourcepub fn expires(&self) -> Option<Expiration>
pub fn expires(&self) -> Option<Expiration>
Returns the Expiration of the cookie if one was specified.
Example
use cookie::{Cookie, Expiration};
let c = Cookie::parse("name=value").unwrap();
assert_eq!(c.expires(), None);
// Here, `cookie.expires_datetime()` returns `None`.
let c = Cookie::build("name", "value").expires(None).finish();
assert_eq!(c.expires(), Some(Expiration::Session));
let expire_time = "Wed, 21 Oct 2017 07:28:00 GMT";
let cookie_str = format!("name=value; Expires={}", expire_time);
let c = Cookie::parse(cookie_str).unwrap();
assert_eq!(c.expires().and_then(|e| e.datetime()).map(|t| t.year()), Some(2017));sourcepub fn expires_datetime(&self) -> Option<OffsetDateTime>
pub fn expires_datetime(&self) -> Option<OffsetDateTime>
Returns the expiration date-time of the cookie if one was specified.
Example
use cookie::Cookie;
let c = Cookie::parse("name=value").unwrap();
assert_eq!(c.expires_datetime(), None);
// Here, `cookie.expires()` returns `Some`.
let c = Cookie::build("name", "value").expires(None).finish();
assert_eq!(c.expires_datetime(), None);
let expire_time = "Wed, 21 Oct 2017 07:28:00 GMT";
let cookie_str = format!("name=value; Expires={}", expire_time);
let c = Cookie::parse(cookie_str).unwrap();
assert_eq!(c.expires_datetime().map(|t| t.year()), Some(2017));sourcepub fn set_name<N>(&mut self, name: N) where
N: Into<Cow<'c, str>>,
pub fn set_name<N>(&mut self, name: N) where
N: Into<Cow<'c, str>>,
Sets the name of self to name.
Example
use cookie::Cookie;
let mut c = Cookie::new("name", "value");
assert_eq!(c.name(), "name");
c.set_name("foo");
assert_eq!(c.name(), "foo");sourcepub fn set_value<V>(&mut self, value: V) where
V: Into<Cow<'c, str>>,
pub fn set_value<V>(&mut self, value: V) where
V: Into<Cow<'c, str>>,
Sets the value of self to value.
Example
use cookie::Cookie;
let mut c = Cookie::new("name", "value");
assert_eq!(c.value(), "value");
c.set_value("bar");
assert_eq!(c.value(), "bar");sourcepub fn set_http_only<T>(&mut self, value: T) where
T: Into<Option<bool>>,
pub fn set_http_only<T>(&mut self, value: T) where
T: Into<Option<bool>>,
Sets the value of http_only in self to value. If value is
None, the field is unset.
Example
use cookie::Cookie;
let mut c = Cookie::new("name", "value");
assert_eq!(c.http_only(), None);
c.set_http_only(true);
assert_eq!(c.http_only(), Some(true));
c.set_http_only(false);
assert_eq!(c.http_only(), Some(false));
c.set_http_only(None);
assert_eq!(c.http_only(), None);sourcepub fn set_secure<T>(&mut self, value: T) where
T: Into<Option<bool>>,
pub fn set_secure<T>(&mut self, value: T) where
T: Into<Option<bool>>,
Sets the value of secure in self to value. If value is None,
the field is unset.
Example
use cookie::Cookie;
let mut c = Cookie::new("name", "value");
assert_eq!(c.secure(), None);
c.set_secure(true);
assert_eq!(c.secure(), Some(true));
c.set_secure(false);
assert_eq!(c.secure(), Some(false));
c.set_secure(None);
assert_eq!(c.secure(), None);sourcepub fn set_same_site<T>(&mut self, value: T) where
T: Into<Option<SameSite>>,
pub fn set_same_site<T>(&mut self, value: T) where
T: Into<Option<SameSite>>,
Sets the value of same_site in self to value. If value is
None, the field is unset. If value is SameSite::None, the “Secure”
flag will be set when the cookie is written out unless secure is
explicitly set to false via Cookie::set_secure() or the equivalent
builder method.
Example
use cookie::{Cookie, SameSite};
let mut c = Cookie::new("name", "value");
assert_eq!(c.same_site(), None);
c.set_same_site(SameSite::None);
assert_eq!(c.same_site(), Some(SameSite::None));
assert_eq!(c.to_string(), "name=value; SameSite=None; Secure");
c.set_secure(false);
assert_eq!(c.to_string(), "name=value; SameSite=None");
let mut c = Cookie::new("name", "value");
assert_eq!(c.same_site(), None);
c.set_same_site(SameSite::Strict);
assert_eq!(c.same_site(), Some(SameSite::Strict));
assert_eq!(c.to_string(), "name=value; SameSite=Strict");
c.set_same_site(None);
assert_eq!(c.same_site(), None);
assert_eq!(c.to_string(), "name=value");sourcepub fn set_max_age<D>(&mut self, value: D) where
D: Into<Option<Duration>>,
pub fn set_max_age<D>(&mut self, value: D) where
D: Into<Option<Duration>>,
Sets the value of max_age in self to value. If value is None,
the field is unset.
Example
use cookie::Cookie;
use cookie::time::Duration;
let mut c = Cookie::new("name", "value");
assert_eq!(c.max_age(), None);
c.set_max_age(Duration::hours(10));
assert_eq!(c.max_age(), Some(Duration::hours(10)));
c.set_max_age(None);
assert!(c.max_age().is_none());sourcepub fn set_path<P>(&mut self, path: P) where
P: Into<Cow<'c, str>>,
pub fn set_path<P>(&mut self, path: P) where
P: Into<Cow<'c, str>>,
Sets the path of self to path.
Example
use cookie::Cookie;
let mut c = Cookie::new("name", "value");
assert_eq!(c.path(), None);
c.set_path("/");
assert_eq!(c.path(), Some("/"));sourcepub fn unset_path(&mut self)
pub fn unset_path(&mut self)
Unsets the path of self.
Example
use cookie::Cookie;
let mut c = Cookie::new("name", "value");
assert_eq!(c.path(), None);
c.set_path("/");
assert_eq!(c.path(), Some("/"));
c.unset_path();
assert_eq!(c.path(), None);sourcepub fn set_domain<D>(&mut self, domain: D) where
D: Into<Cow<'c, str>>,
pub fn set_domain<D>(&mut self, domain: D) where
D: Into<Cow<'c, str>>,
Sets the domain of self to domain.
Example
use cookie::Cookie;
let mut c = Cookie::new("name", "value");
assert_eq!(c.domain(), None);
c.set_domain("rust-lang.org");
assert_eq!(c.domain(), Some("rust-lang.org"));sourcepub fn unset_domain(&mut self)
pub fn unset_domain(&mut self)
Unsets the domain of self.
Example
use cookie::Cookie;
let mut c = Cookie::new("name", "value");
assert_eq!(c.domain(), None);
c.set_domain("rust-lang.org");
assert_eq!(c.domain(), Some("rust-lang.org"));
c.unset_domain();
assert_eq!(c.domain(), None);sourcepub fn set_expires<T>(&mut self, time: T) where
T: Into<Expiration>,
pub fn set_expires<T>(&mut self, time: T) where
T: Into<Expiration>,
Sets the expires field of self to time. If time is None, an
expiration of Session is set.
Example
use cookie::{Cookie, Expiration};
use cookie::time::{Duration, OffsetDateTime};
let mut c = Cookie::new("name", "value");
assert_eq!(c.expires(), None);
let mut now = OffsetDateTime::now_utc();
now += Duration::weeks(52);
c.set_expires(now);
assert!(c.expires().is_some());
c.set_expires(None);
assert_eq!(c.expires(), Some(Expiration::Session));sourcepub fn unset_expires(&mut self)
pub fn unset_expires(&mut self)
Unsets the expires of self.
Example
use cookie::{Cookie, Expiration};
let mut c = Cookie::new("name", "value");
assert_eq!(c.expires(), None);
c.set_expires(None);
assert_eq!(c.expires(), Some(Expiration::Session));
c.unset_expires();
assert_eq!(c.expires(), None);sourcepub fn make_permanent(&mut self)
pub fn make_permanent(&mut self)
Makes self a “permanent” cookie by extending its expiration and max
age 20 years into the future.
Example
use cookie::Cookie;
use cookie::time::Duration;
let mut c = Cookie::new("foo", "bar");
assert!(c.expires().is_none());
assert!(c.max_age().is_none());
c.make_permanent();
assert!(c.expires().is_some());
assert_eq!(c.max_age(), Some(Duration::days(365 * 20)));sourcepub fn make_removal(&mut self)
pub fn make_removal(&mut self)
Make self a “removal” cookie by clearing its value, setting a max-age
of 0, and setting an expiration date far in the past.
Example
use cookie::Cookie;
use cookie::time::Duration;
let mut c = Cookie::new("foo", "bar");
c.make_permanent();
assert_eq!(c.max_age(), Some(Duration::days(365 * 20)));
assert_eq!(c.value(), "bar");
c.make_removal();
assert_eq!(c.value(), "");
assert_eq!(c.max_age(), Some(Duration::ZERO));sourcepub fn name_raw(&self) -> Option<&'c str>
pub fn name_raw(&self) -> Option<&'c str>
Returns the name of self as a string slice of the raw string self
was originally parsed from. If self was not originally parsed from a
raw string, returns None.
This method differs from Cookie::name() in that it returns a string
with the same lifetime as the originally parsed string. This lifetime
may outlive self. If a longer lifetime is not required, or you’re
unsure if you need a longer lifetime, use Cookie::name().
Example
use cookie::Cookie;
let cookie_string = format!("{}={}", "foo", "bar");
// `c` will be dropped at the end of the scope, but `name` will live on
let name = {
let c = Cookie::parse(cookie_string.as_str()).unwrap();
c.name_raw()
};
assert_eq!(name, Some("foo"));sourcepub fn value_raw(&self) -> Option<&'c str>
pub fn value_raw(&self) -> Option<&'c str>
Returns the value of self as a string slice of the raw string self
was originally parsed from. If self was not originally parsed from a
raw string, returns None.
This method differs from Cookie::value() in that it returns a
string with the same lifetime as the originally parsed string. This
lifetime may outlive self. If a longer lifetime is not required, or
you’re unsure if you need a longer lifetime, use Cookie::value().
Example
use cookie::Cookie;
let cookie_string = format!("{}={}", "foo", "bar");
// `c` will be dropped at the end of the scope, but `value` will live on
let value = {
let c = Cookie::parse(cookie_string.as_str()).unwrap();
c.value_raw()
};
assert_eq!(value, Some("bar"));sourcepub fn path_raw(&self) -> Option<&'c str>
pub fn path_raw(&self) -> Option<&'c str>
Returns the Path of self as a string slice of the raw string self
was originally parsed from. If self was not originally parsed from a
raw string, or if self doesn’t contain a Path, or if the Path has
changed since parsing, returns None.
This method differs from Cookie::path() in that it returns a
string with the same lifetime as the originally parsed string. This
lifetime may outlive self. If a longer lifetime is not required, or
you’re unsure if you need a longer lifetime, use Cookie::path().
Example
use cookie::Cookie;
let cookie_string = format!("{}={}; Path=/", "foo", "bar");
// `c` will be dropped at the end of the scope, but `path` will live on
let path = {
let c = Cookie::parse(cookie_string.as_str()).unwrap();
c.path_raw()
};
assert_eq!(path, Some("/"));sourcepub fn domain_raw(&self) -> Option<&'c str>
pub fn domain_raw(&self) -> Option<&'c str>
Returns the Domain of self as a string slice of the raw string
self was originally parsed from. If self was not originally parsed
from a raw string, or if self doesn’t contain a Domain, or if the
Domain has changed since parsing, returns None.
This method differs from Cookie::domain() in that it returns a
string with the same lifetime as the originally parsed string. This
lifetime may outlive self struct. If a longer lifetime is not
required, or you’re unsure if you need a longer lifetime, use
Cookie::domain().
Example
use cookie::Cookie;
let cookie_string = format!("{}={}; Domain=crates.io", "foo", "bar");
//`c` will be dropped at the end of the scope, but `domain` will live on
let domain = {
let c = Cookie::parse(cookie_string.as_str()).unwrap();
c.domain_raw()
};
assert_eq!(domain, Some("crates.io"));sourcepub fn encoded(&'a self) -> Display<'a, 'c>
pub fn encoded(&'a self) -> Display<'a, 'c>
Wraps self in an encoded Display: a cost-free wrapper around
Cookie whose fmt::Display implementation percent-encodes the name
and value of the wrapped Cookie.
The returned structure can be chained with Display::stripped() to
display only the name and value.
Example
use cookie::Cookie;
let mut c = Cookie::build("my name", "this; value?").secure(true).finish();
assert_eq!(&c.encoded().to_string(), "my%20name=this%3B%20value%3F; Secure");
assert_eq!(&c.encoded().stripped().to_string(), "my%20name=this%3B%20value%3F");sourcepub fn stripped(&'a self) -> Display<'a, 'c>
pub fn stripped(&'a self) -> Display<'a, 'c>
Wraps self in a stripped Display]: a cost-free wrapper around
Cookie whose fmt::Display implementation prints only the name
and value of the wrapped Cookie.
The returned structure can be chained with Display::encoded() to
encode the name and value.
Example
use cookie::Cookie;
let mut c = Cookie::build("key?", "value").secure(true).path("/").finish();
assert_eq!(&c.stripped().to_string(), "key?=value");
// Note: `encoded()` is only available when `percent-encode` is enabled.
assert_eq!(&c.stripped().encoded().to_string(), "key%3F=value");Trait Implementations
sourceimpl<'c> Display for Cookie<'c>
impl<'c> Display for Cookie<'c>
sourcefn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
Formats the cookie self as a Set-Cookie header value.
Does not percent-encode any values. To percent-encode, use
Cookie::encoded().
Example
use cookie::Cookie;
let mut cookie = Cookie::build("foo", "bar")
.path("/")
.finish();
assert_eq!(&cookie.to_string(), "foo=bar; Path=/");sourceimpl FromStr for Cookie<'static>
impl FromStr for Cookie<'static>
type Err = ParseError
type Err = ParseError
The associated error which can be returned from parsing.
Auto Trait Implementations
impl<'c> RefUnwindSafe for Cookie<'c>
impl<'c> Send for Cookie<'c>
impl<'c> Sync for Cookie<'c>
impl<'c> Unpin for Cookie<'c>
impl<'c> UnwindSafe for Cookie<'c>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> FmtForward for T
impl<T> FmtForward for T
fn fmt_binary(self) -> FmtBinary<Self> where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self> where
Self: Binary,
Causes self to use its Binary implementation when Debug-formatted.
fn fmt_display(self) -> FmtDisplay<Self> where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self> where
Self: Display,
Causes self to use its Display implementation when
Debug-formatted. Read more
fn fmt_lower_exp(self) -> FmtLowerExp<Self> where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self> where
Self: LowerExp,
Causes self to use its LowerExp implementation when
Debug-formatted. Read more
fn fmt_lower_hex(self) -> FmtLowerHex<Self> where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self> where
Self: LowerHex,
Causes self to use its LowerHex implementation when
Debug-formatted. Read more
fn fmt_octal(self) -> FmtOctal<Self> where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self> where
Self: Octal,
Causes self to use its Octal implementation when Debug-formatted.
fn fmt_pointer(self) -> FmtPointer<Self> where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self> where
Self: Pointer,
Causes self to use its Pointer implementation when
Debug-formatted. Read more
fn fmt_upper_exp(self) -> FmtUpperExp<Self> where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self> where
Self: UpperExp,
Causes self to use its UpperExp implementation when
Debug-formatted. Read more
fn fmt_upper_hex(self) -> FmtUpperHex<Self> where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self> where
Self: UpperHex,
Causes self to use its UpperHex implementation when
Debug-formatted. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T, U, I> LiftInto<U, I> for T where
U: LiftFrom<T, I>,
impl<T, U, I> LiftInto<U, I> for T where
U: LiftFrom<T, I>,
fn lift_into(self) -> U
fn lift_into(self) -> U
Performs the indexed conversion.
impl<T> Pipe for T where
T: ?Sized,
impl<T> Pipe for T where
T: ?Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
Pipes by value. This is generally the method you want to use. Read more
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R where
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R where
R: 'a,
Borrows self and passes that borrow into the pipe function. Read more
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R where
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R where
R: 'a,
Mutably borrows self and passes that borrow into the pipe function. Read more
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R where
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R where
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
Borrows self, then passes self.borrow() into the pipe function. Read more
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R where
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R where
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
Mutably borrows self, then passes self.borrow_mut() into the pipe
function. Read more
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R where
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R where
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
Borrows self, then passes self.as_ref() into the pipe function.
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R where
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R where
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
Mutably borrows self, then passes self.as_mut() into the pipe
function. Read more
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: Deref<Target = T>,
T: 'a + ?Sized,
R: 'a,
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: Deref<Target = T>,
T: 'a + ?Sized,
R: 'a,
Borrows self, then passes self.deref() into the pipe function.
impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Tap for T
impl<T> Tap for T
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self where
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self where
Self: Borrow<B>,
B: ?Sized,
Immutable access to the Borrow<B> of a value. Read more
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self where
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self where
Self: BorrowMut<B>,
B: ?Sized,
Mutable access to the BorrowMut<B> of a value. Read more
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self where
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self where
Self: AsRef<R>,
R: ?Sized,
Immutable access to the AsRef<R> view of a value. Read more
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self where
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self where
Self: AsMut<R>,
R: ?Sized,
Mutable access to the AsMut<R> view of a value. Read more
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self where
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self where
Self: Deref<Target = T>,
T: ?Sized,
Immutable access to the Deref::Target of a value. Read more
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self where
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self where
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
Mutable access to the Deref::Target of a value. Read more
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
Calls .tap() only in debug builds, and is erased in release builds.
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls .tap_mut() only in debug builds, and is erased in release
builds. Read more
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self where
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self where
Self: Borrow<B>,
B: ?Sized,
Calls .tap_borrow() only in debug builds, and is erased in release
builds. Read more
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self where
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self where
Self: BorrowMut<B>,
B: ?Sized,
Calls .tap_borrow_mut() only in debug builds, and is erased in release
builds. Read more
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self where
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self where
Self: AsRef<R>,
R: ?Sized,
Calls .tap_ref() only in debug builds, and is erased in release
builds. Read more
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self where
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self where
Self: AsMut<R>,
R: ?Sized,
Calls .tap_ref_mut() only in debug builds, and is erased in release
builds. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more