Struct isahc::cookies::CookieBuilder
source · [−]pub struct CookieBuilder { /* private fields */ }
cookies
only.Expand description
Builder for a Cookie
.
use isahc::cookies::Cookie;
use std::time::{Duration, SystemTime};
let cookie: Cookie = Cookie::builder("name", "value") // or CookieBuilder::new("name", "value")
.domain("example.com")
.path("/")
.secure(true)
.expiration(SystemTime::now() + Duration::from_secs(30 * 60))
.build()
.unwrap();
Implementations
sourceimpl CookieBuilder
impl CookieBuilder
sourcepub fn new<N, V>(name: N, value: V) -> Self where
N: Into<String>,
V: Into<String>,
pub fn new<N, V>(name: N, value: V) -> Self where
N: Into<String>,
V: Into<String>,
Create a new cookie builder with a given name and value.
sourcepub fn domain<S>(self, domain: S) -> Self where
S: Into<String>,
pub fn domain<S>(self, domain: S) -> Self where
S: Into<String>,
Sets the domain the cookie belongs to.
sourcepub fn path<S>(self, path: S) -> Self where
S: Into<String>,
pub fn path<S>(self, path: S) -> Self where
S: Into<String>,
Sets the path prefix that this cookie belongs to.
sourcepub fn secure(self, secure: bool) -> Self
pub fn secure(self, secure: bool) -> Self
True if the cookie is marked as secure (limited in scope to HTTPS).
sourcepub fn expiration<T>(self, expiration: T) -> Self where
T: Into<SystemTime>,
pub fn expiration<T>(self, expiration: T) -> Self where
T: Into<SystemTime>,
Time when this cookie expires. If not present, then this is a session cookie that expires when the current client session ends.
sourcepub fn build(self) -> Result<Cookie, ParseError>
pub fn build(self) -> Result<Cookie, ParseError>
Builds the cookie.
Returns an error if either the name or value given contains illegal characters. In practice, only a subset of US-ASCII characters are allowed in cookies for maximum compatibility with most web servers.
Trait Implementations
sourceimpl Clone for CookieBuilder
impl Clone for CookieBuilder
sourcefn clone(&self) -> CookieBuilder
fn clone(&self) -> CookieBuilder
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl RefUnwindSafe for CookieBuilder
impl Send for CookieBuilder
impl Sync for CookieBuilder
impl Unpin for CookieBuilder
impl UnwindSafe for CookieBuilder
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
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
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
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