Skip to main content

ResponseCookie

Struct ResponseCookie 

Source
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: String

Cookie name.

§value: String

Opaque cookie value.

§path: Option<String>

Optional path scope.

§domain: Option<String>

Optional domain scope.

§max_age: Option<Duration>

Optional relative lifetime.

§secure: bool

Restricts transmission to secure transports.

§http_only: bool

Hides the cookie from browser scripting APIs.

§same_site: Option<SameSite>

Browser cross-site behavior.

Implementations§

Source§

impl ResponseCookie

Source

pub fn new( name: impl Into<String>, value: impl Into<String>, ) -> SoapResult<Self>

Creates a validated cookie with secure HTTP-only defaults.

Source

pub fn remove(name: impl Into<String>) -> SoapResult<Self>

Creates a secure cookie deletion effect using Max-Age=0.

Source

pub fn path(self, path: impl Into<String>) -> SoapResult<Self>

Sets the cookie path.

Source

pub fn domain(self, domain: impl Into<String>) -> SoapResult<Self>

Sets the cookie domain.

Source

pub const fn max_age(self, max_age: Duration) -> Self

Sets a relative lifetime. Zero represents immediate deletion.

Source

pub fn same_site(self, same_site: SameSite) -> SoapResult<Self>

Changes browser cross-site behavior.

Source

pub fn insecure(self) -> SoapResult<Self>

Allows transmission over insecure transport for local development.

This is rejected while SameSite=None is selected.

Source

pub const fn script_accessible(self) -> Self

Makes the cookie visible to browser scripts.

Source

pub fn validate(&self) -> SoapResult<()>

Validates cookie attributes after direct public-field mutation.

Trait Implementations§

Source§

impl Clone for ResponseCookie

Source§

fn clone(&self) -> ResponseCookie

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ResponseCookie

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for ResponseCookie

Source§

impl PartialEq for ResponseCookie

Source§

fn eq(&self, other: &ResponseCookie) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ResponseCookie

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.