pub trait OutgoingConfig: CookieName {
type Insert: Serialize;
// Provided methods
fn serialize(values: Self::Insert) -> Value { ... }
fn attributes<'c>() -> Attributes<'c> { ... }
}Expand description
Provide internal customization for insert and remove methods in Cookie.
The insert and remove will be available when types that implement this trait is used as generic parameters for Cookie.
use cookiebox::cookiebox_macros::cookie;
use cookiebox::cookies::{CookieName, OutgoingConfig};
// Define a generic cookie type
#[cookie(name = "__my-cookie")]
pub struct MyCookie;
impl OutgoingConfig for MyCookie {
// Configure the insert type
type Insert = String;
// The default serialization is used here, if customization is needed, implement the `serialize` method.
// The default attributes is used here which consists of http-only: true, SameSite: Lax, and
// path: "/"
}Required Associated Types§
Provided Methods§
Sourcefn serialize(values: Self::Insert) -> Value
fn serialize(values: Self::Insert) -> Value
Provides default serialization for a cookie. This can be overwriting
Sourcefn attributes<'c>() -> Attributes<'c>
fn attributes<'c>() -> Attributes<'c>
Provides preset attributes for a cookie. This can be overwriting
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.