pub struct Cookie {
pub name: String,
pub value: String,
pub domain: Option<String>,
pub path: Option<String>,
pub secure: Option<bool>,
pub http_only: Option<bool>,
pub same_site: Option<String>,
pub expiration_date: Option<f64>,
}Expand description
Browser cookie with standard properties.
Fields§
§name: StringCookie name.
value: StringCookie value.
domain: Option<String>Domain.
path: Option<String>Path.
secure: Option<bool>Secure flag.
http_only: Option<bool>HttpOnly flag.
same_site: Option<String>SameSite attribute.
expiration_date: Option<f64>Expiration timestamp (seconds).
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
Creates a new cookie with name and value.
Sourcepub fn with_domain(self, domain: impl Into<String>) -> Self
pub fn with_domain(self, domain: impl Into<String>) -> Self
Sets the domain.
Sourcepub fn with_secure(self, secure: bool) -> Self
pub fn with_secure(self, secure: bool) -> Self
Sets the secure flag.
Sourcepub fn with_http_only(self, http_only: bool) -> Self
pub fn with_http_only(self, http_only: bool) -> Self
Sets the httpOnly flag.
Sourcepub fn with_same_site(self, same_site: impl Into<String>) -> Self
pub fn with_same_site(self, same_site: impl Into<String>) -> Self
Sets the sameSite attribute.
Sourcepub fn with_expiration_date(self, expiration_date: f64) -> Self
pub fn with_expiration_date(self, expiration_date: f64) -> Self
Sets the expiration date.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Cookie
impl<'de> Deserialize<'de> for Cookie
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Cookie
impl RefUnwindSafe for Cookie
impl Send for Cookie
impl Sync for Cookie
impl Unpin 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