pub struct Cookie {
pub name: String,
pub value: String,
pub domain: Option<String>,
pub path: Option<String>,
pub max_age: Option<Duration>,
pub secure: bool,
pub http_only: bool,
pub same_site: Option<SameSite>,
pub expires_at: Option<Instant>,
}Expand description
Represents a single HTTP cookie.
Fields§
§name: String§value: String§domain: Option<String>§path: Option<String>§max_age: Option<Duration>Max-Age attribute stored as a Duration.
secure: bool§http_only: bool§same_site: Option<SameSite>§expires_at: Option<Instant>Computed absolute expiry time from max_age, set at insertion.
Implementations§
Source§impl Cookie
impl Cookie
Sourcepub fn new(name: impl Into<String>, value: impl Into<String>) -> Self
pub fn new(name: impl Into<String>, value: impl Into<String>) -> Self
Create a new cookie with the given name and value.
Sourcepub fn is_http_only(&self) -> bool
pub fn is_http_only(&self) -> bool
Whether the HttpOnly flag is set.
Sourcepub fn set_domain(self, domain: impl Into<String>) -> Self
pub fn set_domain(self, domain: impl Into<String>) -> Self
Set the domain attribute.
Sourcepub fn set_max_age(self, seconds: u64) -> Self
pub fn set_max_age(self, seconds: u64) -> Self
Set the max-age attribute in seconds.
Sourcepub fn set_secure(self, secure: bool) -> Self
pub fn set_secure(self, secure: bool) -> Self
Set the Secure flag.
Sourcepub fn set_http_only(self, http_only: bool) -> Self
pub fn set_http_only(self, http_only: bool) -> Self
Set the HttpOnly flag.
Sourcepub fn set_same_site(self, same_site: SameSite) -> Self
pub fn set_same_site(self, same_site: SameSite) -> Self
Set the SameSite attribute.
Parse a cookie from a Set-Cookie header value (RFC 6265).
expires_at is left as None here; it is computed at insertion time by CookieJar.
Serialize the cookie for use in a Cookie request header.
Trait Implementations§
impl Eq for Cookie
impl StructuralPartialEq for Cookie
Auto Trait Implementations§
impl Freeze for Cookie
impl RefUnwindSafe for Cookie
impl Send for Cookie
impl Sync for Cookie
impl Unpin for Cookie
impl UnsafeUnpin for Cookie
impl UnwindSafe for Cookie
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more