pub struct CookieBuilder { /* private fields */ }
Available on crate feature 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

Create a new cookie builder with a given name and value.

Sets the domain the cookie belongs to.

Note that the domain will be preserved exactly as supplied. If the string has a . prefix that should be ignored (such as allowed by the Set-Cookie HTTP header), then you must remove it manually first.

Sets the path prefix that this cookie belongs to.

True if the cookie is marked as secure (limited in scope to HTTPS).

Time when this cookie expires. If not present, then this is a session cookie that expires when the current client session ends.

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

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more