pub struct Cookie {
pub name: String,
pub value: String,
pub domain: String,
pub path: String,
pub expires: Option<u64>,
pub max_age: Option<i64>,
pub secure: bool,
pub http_only: bool,
pub same_site: SameSite,
pub host_only: bool,
pub created_at: u64,
pub last_accessed: u64,
}Expand description
An authentic RFC 6265 HTTP Cookie.
Fields§
§name: String§value: String§domain: String§path: String§expires: Option<u64>§max_age: Option<i64>§secure: bool§http_only: bool§same_site: SameSite§host_only: bool§created_at: u64§last_accessed: u64Implementations§
Source§impl Cookie
impl Cookie
Sourcepub fn new(
name: impl Into<String>,
value: impl Into<String>,
domain: impl Into<String>,
) -> Self
pub fn new( name: impl Into<String>, value: impl Into<String>, domain: impl Into<String>, ) -> Self
Constructs a basic cookie with default path “/” and current timestamp.
Sourcepub fn parse(header_value: &str, request_url: &str) -> Option<Self>
pub fn parse(header_value: &str, request_url: &str) -> Option<Self>
Parses a Set-Cookie response header string in the context of an HTTP request URL.
Sourcepub fn parse_with_context(
header_value: &str,
parsed_url: &ParsedUrl,
now: u64,
) -> Option<Self>
pub fn parse_with_context( header_value: &str, parsed_url: &ParsedUrl, now: u64, ) -> Option<Self>
Parses a Set-Cookie string with an explicit timestamp and parsed request URL.
Sourcepub fn is_expired(&self, now: u64) -> bool
pub fn is_expired(&self, now: u64) -> bool
Evaluates whether this cookie has expired relative to now timestamp in seconds.
Sourcepub fn matches_request(&self, parsed_url: &ParsedUrl, now: u64) -> bool
pub fn matches_request(&self, parsed_url: &ParsedUrl, now: u64) -> bool
Evaluates whether this cookie matches an outgoing request URL per RFC 6265 §5.4.
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
impl Eq for Cookie
impl StructuralPartialEq for Cookie
Auto Trait Implementations§
impl Forget for Cookie
impl Freeze for Cookie
impl Move 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