pub struct CookieBuilder { /* private fields */ }Expand description
Builder for constructing HTTP cookies.
Provides methods to set various cookie attributes like expiration, domain, path, and security flags before building the final cookie string.
Implementations§
Source§impl CookieBuilder
Implementation for CookieBuilder.
impl CookieBuilder
Implementation for CookieBuilder.
Sourcepub fn parse<C>(cookie: C) -> Self
pub fn parse<C>(cookie: C) -> Self
Parses a Set-Cookie header string into a CookieBuilder.
This method takes a Set-Cookie header string and extracts the various
attributes of a cookie, populating a CookieBuilder instance.
§Arguments
AsRef<str>- TheSet-Cookieheader string to parse.
§Returns
A CookieBuilder instance populated with the parsed cookie attributes.
Sourcepub fn set_expires<E>(&mut self, expires: E) -> &mut Self
pub fn set_expires<E>(&mut self, expires: E) -> &mut Self
Sourcepub fn set_max_age<M>(&mut self, max_age: M) -> &mut Self
pub fn set_max_age<M>(&mut self, max_age: M) -> &mut Self
Sourcepub fn set_domain<D>(&mut self, domain: D) -> &mut Self
pub fn set_domain<D>(&mut self, domain: D) -> &mut Self
Sourcepub fn secure(&mut self) -> &mut Self
pub fn secure(&mut self) -> &mut Self
Sets the Secure flag for the cookie.
This flag indicates that the cookie should only be transmitted over secure (HTTPS) connections.
§Returns
The CookieBuilder instance for method chaining.
Sourcepub fn http_only(&mut self) -> &mut Self
pub fn http_only(&mut self) -> &mut Self
Sets the HttpOnly flag for the cookie.
This flag prevents client-side JavaScript from accessing the cookie.
§Returns
The CookieBuilder instance for method chaining.
Sourcepub fn disable_secure(&mut self) -> &mut Self
pub fn disable_secure(&mut self) -> &mut Self
Explicitly disables the Secure flag for the cookie.
This method explicitly sets the Secure flag to false, which may be useful
for overriding default secure settings or for testing purposes.
§Returns
The CookieBuilder instance for method chaining.
Sourcepub fn disable_http_only(&mut self) -> &mut Self
pub fn disable_http_only(&mut self) -> &mut Self
Explicitly disables the HttpOnly flag for the cookie.
This method explicitly sets the HttpOnly flag to false, which may be useful
for overriding default HttpOnly settings or for testing purposes.
§Returns
The CookieBuilder instance for method chaining.
Sourcepub fn set_same_site<T>(&mut self, same_site: T) -> &mut Self
pub fn set_same_site<T>(&mut self, same_site: T) -> &mut Self
Source§impl CookieBuilder
impl CookieBuilder
pub fn get_name(&self) -> &CookieKey
pub fn get_value(&self) -> &CookieValue
pub fn get_expires(&self) -> &Option<String>
pub fn get_max_age(&self) -> &Option<i64>
pub fn get_domain(&self) -> &Option<String>
pub fn get_path(&self) -> &Option<String>
pub fn get_secure(&self) -> &Option<bool>
pub fn get_http_only(&self) -> &Option<bool>
pub fn get_same_site(&self) -> &Option<String>
Source§impl CookieBuilder
impl CookieBuilder
pub fn get_mut_name(&mut self) -> &mut CookieKey
pub fn get_mut_value(&mut self) -> &mut CookieValue
pub fn get_mut_expires(&mut self) -> &mut Option<String>
pub fn get_mut_max_age(&mut self) -> &mut Option<i64>
pub fn get_mut_domain(&mut self) -> &mut Option<String>
pub fn get_mut_path(&mut self) -> &mut Option<String>
pub fn get_mut_secure(&mut self) -> &mut Option<bool>
pub fn get_mut_http_only(&mut self) -> &mut Option<bool>
pub fn get_mut_same_site(&mut self) -> &mut Option<String>
Trait Implementations§
Source§impl Clone for CookieBuilder
impl Clone for CookieBuilder
Source§fn clone(&self) -> CookieBuilder
fn clone(&self) -> CookieBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more