Struct leptos_use::UseCookieOptions

source ·
pub struct UseCookieOptions<T, Err> { /* private fields */ }
Expand description

Implementations§

source§

impl<T, Err> UseCookieOptions<T, Err>

source

pub fn max_age<OptionInnerType>( self, value: impl Into<Option<OptionInnerType>> ) -> Self
where OptionInnerType: Into<i64>,

Max-Age of the cookie in milliseconds. The returned signal will turn to None after the max age is reached. Default: None

The cookie storage model specification states that if both expires and max_age is set, then max_age takes precedence, but not all clients may obey this, so if both are set, they should point to the same date and time!

If neither of expires and max_age is set, the cookie will be session-only and removed when the user closes their browser.

source

pub fn expires<OptionInnerType>( self, value: impl Into<Option<OptionInnerType>> ) -> Self
where OptionInnerType: Into<i64>,

Expiration date-time of the cookie as UNIX timestamp in seconds. The signal will turn to None after the expiration date-time is reached. Default: None

The cookie storage model specification states that if both expires and max_age is set, then max_age takes precedence, but not all clients may obey this, so if both are set, they should point to the same date and time!

If neither of expires and max_age is set, the cookie will be session-only and removed when the user closes their browser.

source

pub fn http_only(self, value: bool) -> Self

Specifies the HttpOnly cookie attribute. When true, the HttpOnly attribute is set; otherwise it is not. By default, the HttpOnly attribute is not set.

Be careful when setting this to true, as compliant clients will not allow client-side JavaScript to see the cookie in document.cookie.

source

pub fn secure(self, value: bool) -> Self

Specifies the value for the Secure cookie attribute. When true, the Secure attribute is set; otherwise it is not. By default, the Secure attribute is not set.

Be careful when setting this to true, as compliant clients will not send the cookie back to the server in the future if the browser does not have an HTTPS connection. This can lead to hydration errors.

source

pub fn domain<OptionInnerType>( self, value: impl Into<Option<OptionInnerType>> ) -> Self
where OptionInnerType: Into<String>,

Specifies the value for the Domain cookie attribute. By default, no domain is set, and most clients will consider applying the cookie only to the current domain.

source

pub fn path<OptionInnerType>( self, value: impl Into<Option<OptionInnerType>> ) -> Self
where OptionInnerType: Into<String>,

Specifies the value for the Path cookie attribute. By default, the path is considered the “default path”.

source

pub fn same_site<OptionInnerType>( self, value: impl Into<Option<OptionInnerType>> ) -> Self
where OptionInnerType: Into<SameSite>,

Specifies the value for the SameSite cookie attribute.

  • 'Some(SameSite::Lax)' will set the SameSite attribute to Lax for lax same-site enforcement.
  • 'Some(SameSite::None)' will set the SameSite attribute to None for an explicit cross-site cookie.
  • 'Some(SameSite::Strict)' will set the SameSite attribute to Strict for strict same-site enforcement.
  • None will not set the SameSite attribute (default).

More information about the different enforcement levels can be found in the specification.

source

pub fn default_value<New__T>( self, value: Option<New__T> ) -> UseCookieOptions<New__T, Err>

The default cookie value in case the cookie is not set. Defaults to None.

source

pub fn readonly(self, value: bool) -> Self

If true the returned WriteSignal will not affect the actual cookie. Default: false

source

pub fn ssr_cookies_header_getter( self, value: impl Fn() -> Option<String> + 'static ) -> Self

Getter function to return the string value of the cookie header. When you use one of the features "axum", "actix" or "spin" there’s a valid default implementation provided.

Function to add a set cookie header to the response on the server. When you use one of the features "axum", "actix" or "spin" there’s a valid default implementation provided.

source

pub fn on_error<New__Err>( self, value: Rc<dyn Fn(New__Err)> ) -> UseCookieOptions<T, New__Err>

Callback for encoding/decoding errors. Defaults to logging the error to the console.

Trait Implementations§

source§

impl<T, Err> Default for UseCookieOptions<T, Err>

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T, Err> Freeze for UseCookieOptions<T, Err>
where T: Freeze,

§

impl<T, Err> !RefUnwindSafe for UseCookieOptions<T, Err>

§

impl<T, Err> !Send for UseCookieOptions<T, Err>

§

impl<T, Err> !Sync for UseCookieOptions<T, Err>

§

impl<T, Err> Unpin for UseCookieOptions<T, Err>
where T: Unpin,

§

impl<T, Err> !UnwindSafe for UseCookieOptions<T, Err>

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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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 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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T, U> TryFrom<U> for T
where 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 T
where 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.
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