Struct leptos_use::UseCookieOptions
source · pub struct UseCookieOptions<T, Err> { /* private fields */ }
Expand description
Options for use_cookie_with_options
.
Implementations§
source§impl<T, Err> UseCookieOptions<T, Err>
impl<T, Err> UseCookieOptions<T, Err>
sourcepub fn max_age<OptionInnerType>(
self,
value: impl Into<Option<OptionInnerType>>
) -> Self
pub fn max_age<OptionInnerType>( self, value: impl Into<Option<OptionInnerType>> ) -> Self
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
andmax_age
is set, thenmax_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
andmax_age
is set, the cookie will be session-only and removed when the user closes their browser.
sourcepub fn expires<OptionInnerType>(
self,
value: impl Into<Option<OptionInnerType>>
) -> Self
pub fn expires<OptionInnerType>( self, value: impl Into<Option<OptionInnerType>> ) -> Self
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
andmax_age
is set, thenmax_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
andmax_age
is set, the cookie will be session-only and removed when the user closes their browser.
sourcepub fn http_only(self, value: bool) -> Self
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 indocument.cookie
.
sourcepub fn secure(self, value: bool) -> Self
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.
sourcepub fn domain<OptionInnerType>(
self,
value: impl Into<Option<OptionInnerType>>
) -> Self
pub fn domain<OptionInnerType>( self, value: impl Into<Option<OptionInnerType>> ) -> Self
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.
sourcepub fn path<OptionInnerType>(
self,
value: impl Into<Option<OptionInnerType>>
) -> Self
pub fn path<OptionInnerType>( self, value: impl Into<Option<OptionInnerType>> ) -> Self
Specifies the value for the Path
cookie attribute.
By default, the path is considered the “default path”.
sourcepub fn same_site<OptionInnerType>(
self,
value: impl Into<Option<OptionInnerType>>
) -> Self
pub fn same_site<OptionInnerType>( self, value: impl Into<Option<OptionInnerType>> ) -> Self
Specifies the value for the SameSite
cookie attribute.
'Some(SameSite::Lax)'
will set theSameSite
attribute toLax
for lax same-site enforcement.'Some(SameSite::None)'
will set theSameSite
attribute toNone
for an explicit cross-site cookie.'Some(SameSite::Strict)'
will set theSameSite
attribute toStrict
for strict same-site enforcement.None
will not set theSameSite
attribute (default).
More information about the different enforcement levels can be found in the specification.
sourcepub fn default_value<New__T>(
self,
value: Option<New__T>
) -> UseCookieOptions<New__T, Err>
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
.
sourcepub fn readonly(self, value: bool) -> Self
pub fn readonly(self, value: bool) -> Self
If true
the returned WriteSignal
will not affect the actual cookie.
Default: false
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.
sourcepub fn on_error<New__Err>(
self,
value: Rc<dyn Fn(New__Err)>
) -> UseCookieOptions<T, New__Err>
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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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