Enum axum_sessions::SameSite

source ยท
pub enum SameSite {
    Strict,
    Lax,
    None,
}
Expand description

The SameSite cookie attribute.

A cookie with a SameSite attribute is imposed restrictions on when it is sent to the origin server in a cross-site request. If the SameSite attribute is โ€œStrictโ€, then the cookie is never sent in cross-site requests. If the SameSite attribute is โ€œLaxโ€, the cookie is only sent in cross-site requests with โ€œsafeโ€ HTTP methods, i.e, GET, HEAD, OPTIONS, TRACE. If the SameSite attribute is โ€œNoneโ€, the cookie is sent in all cross-site requests if the โ€œSecureโ€ flag is also set, otherwise the cookie is ignored. This library automatically sets the โ€œSecureโ€ flag on cookies when same_site is set to SameSite::None as long as secure is not explicitly set to false.

If the SameSite attribute is not present (by not setting SameSite initally or passing None to Cookie::set_same_site()), then the cookie will be sent as normal.

Note: This cookie attribute is an HTTP draft! Its meaning and definition are subject to change.

Variantsยง

ยง

Strict

The โ€œStrictโ€ SameSite attribute.

ยง

Lax

The โ€œLaxโ€ SameSite attribute.

ยง

None

The โ€œNoneโ€ SameSite attribute.

Implementationsยง

sourceยง

impl SameSite

source

pub fn is_strict(&self) -> bool

Returns true if self is SameSite::Strict and false otherwise.

Example
use cookie::SameSite;

let strict = SameSite::Strict;
assert!(strict.is_strict());
assert!(!strict.is_lax());
assert!(!strict.is_none());
source

pub fn is_lax(&self) -> bool

Returns true if self is SameSite::Lax and false otherwise.

Example
use cookie::SameSite;

let lax = SameSite::Lax;
assert!(lax.is_lax());
assert!(!lax.is_strict());
assert!(!lax.is_none());
source

pub fn is_none(&self) -> bool

Returns true if self is SameSite::None and false otherwise.

Example
use cookie::SameSite;

let none = SameSite::None;
assert!(none.is_none());
assert!(!none.is_lax());
assert!(!none.is_strict());

Trait Implementationsยง

sourceยง

impl Clone for SameSite

sourceยง

fn clone(&self) -> SameSite

Returns a copy of the value. Read more
1.0.0 ยท sourceยง

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

Performs copy-assignment from source. Read more
sourceยง

impl Debug for SameSite

sourceยง

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

Formats the value using the given formatter. Read more
sourceยง

impl Display for SameSite

sourceยง

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

Formats the value using the given formatter. Read more
sourceยง

impl Hash for SameSite

sourceยง

fn hash<__H>(&self, state: &mut __H)where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 ยท sourceยง

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
sourceยง

impl PartialEq for SameSite

sourceยง

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 ยท sourceยง

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
sourceยง

impl Copy for SameSite

sourceยง

impl Eq for SameSite

sourceยง

impl StructuralEq for SameSite

sourceยง

impl StructuralPartialEq for SameSite

Auto Trait Implementationsยง

Blanket Implementationsยง

sourceยง

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

sourceยง

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
sourceยง

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

sourceยง

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
sourceยง

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

sourceยง

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

Mutably borrows from an owned value. Read more
sourceยง

impl<T> From<T> for T

sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

ยง

impl<T> FromRef<T> for Twhere T: Clone,

ยง

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
sourceยง

impl<T> Instrument for T

sourceยง

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
sourceยง

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
sourceยง

impl<T, U> Into<U> for Twhere 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> Same for T

ยง

type Output = T

Should always be Self
sourceยง

impl<T> ToOwned for Twhere T: Clone,

ยง

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> ToString for Twhere T: Display + ?Sized,

sourceยง

default fn to_string(&self) -> String

Converts the given value to a String. Read more
sourceยง

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

ยง

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 Twhere U: TryFrom<T>,

ยง

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.
ยง

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

ยง

fn vzip(self) -> V

sourceยง

impl<T> WithSubscriber for T

sourceยง

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
sourceยง

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more