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

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());

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());

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

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementationsยง

Blanket Implementationsยง

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Converts to this type from a reference to the input type.
Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more