pub struct ResponseCookie {
pub name: String,
pub value: String,
pub path: Option<String>,
pub domain: Option<String>,
pub max_age: Option<Duration>,
pub secure: bool,
pub http_only: bool,
pub same_site: Option<SameSite>,
}Expand description
Transport-neutral cookie mutation returned by HTTP modules.
Fields§
§name: StringCookie name.
value: StringOpaque cookie value.
path: Option<String>Optional path scope.
domain: Option<String>Optional domain scope.
max_age: Option<Duration>Optional relative lifetime.
secure: boolRestricts transmission to secure transports.
http_only: boolHides the cookie from browser scripting APIs.
same_site: Option<SameSite>Browser cross-site behavior.
Implementations§
Source§impl ResponseCookie
impl ResponseCookie
Sourcepub fn new(
name: impl Into<String>,
value: impl Into<String>,
) -> SoapResult<Self>
pub fn new( name: impl Into<String>, value: impl Into<String>, ) -> SoapResult<Self>
Creates a validated cookie with secure HTTP-only defaults.
Sourcepub fn remove(name: impl Into<String>) -> SoapResult<Self>
pub fn remove(name: impl Into<String>) -> SoapResult<Self>
Creates a secure cookie deletion effect using Max-Age=0.
Sourcepub fn path(self, path: impl Into<String>) -> SoapResult<Self>
pub fn path(self, path: impl Into<String>) -> SoapResult<Self>
Sets the cookie path.
Sourcepub fn domain(self, domain: impl Into<String>) -> SoapResult<Self>
pub fn domain(self, domain: impl Into<String>) -> SoapResult<Self>
Sets the cookie domain.
Sourcepub const fn max_age(self, max_age: Duration) -> Self
pub const fn max_age(self, max_age: Duration) -> Self
Sets a relative lifetime. Zero represents immediate deletion.
Sourcepub fn same_site(self, same_site: SameSite) -> SoapResult<Self>
pub fn same_site(self, same_site: SameSite) -> SoapResult<Self>
Changes browser cross-site behavior.
Sourcepub fn insecure(self) -> SoapResult<Self>
pub fn insecure(self) -> SoapResult<Self>
Allows transmission over insecure transport for local development.
This is rejected while SameSite=None is selected.
Sourcepub const fn script_accessible(self) -> Self
pub const fn script_accessible(self) -> Self
Makes the cookie visible to browser scripts.
Sourcepub fn validate(&self) -> SoapResult<()>
pub fn validate(&self) -> SoapResult<()>
Validates cookie attributes after direct public-field mutation.
Trait Implementations§
Source§impl Clone for ResponseCookie
impl Clone for ResponseCookie
Source§fn clone(&self) -> ResponseCookie
fn clone(&self) -> ResponseCookie
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more