pub struct UseCookieOptions<T, E, D> { /* private fields */ }Expand description
Options for use_cookie_with_options.
Implementations§
Source§impl<T, E, D> UseCookieOptions<T, E, D>
impl<T, E, D> UseCookieOptions<T, E, D>
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
expiresandmax_ageis set, thenmax_agetakes 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
expiresandmax_ageis 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
expiresandmax_ageis set, thenmax_agetakes 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
expiresandmax_ageis 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 theSameSiteattribute toLaxfor lax same-site enforcement.'Some(SameSite::None)'will set theSameSiteattribute toNonefor an explicit cross-site cookie.'Some(SameSite::Strict)'will set theSameSiteattribute toStrictfor strict same-site enforcement.Nonewill not set theSameSiteattribute (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, E, D>
pub fn default_value<New__T>( self, value: Option<New__T>, ) -> UseCookieOptions<New__T, E, D>
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__E, New__D>(
self,
value: Arc<dyn Fn(CodecError<New__E, New__D>) + Send + Sync>,
) -> UseCookieOptions<T, New__E, New__D>
pub fn on_error<New__E, New__D>( self, value: Arc<dyn Fn(CodecError<New__E, New__D>) + Send + Sync>, ) -> UseCookieOptions<T, New__E, New__D>
Callback for encoding/decoding errors. Defaults to logging the error to the console.
Trait Implementations§
Auto Trait Implementations§
impl<T, E, D> Freeze for UseCookieOptions<T, E, D>where
T: Freeze,
impl<T, E, D> !RefUnwindSafe for UseCookieOptions<T, E, D>
impl<T, E, D> Send for UseCookieOptions<T, E, D>where
T: Send,
impl<T, E, D> Sync for UseCookieOptions<T, E, D>where
T: Sync,
impl<T, E, D> Unpin for UseCookieOptions<T, E, D>where
T: Unpin,
impl<T, E, D> !UnwindSafe for UseCookieOptions<T, E, D>
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> 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