pub struct SessionConfig {
pub cookie_name: String,
pub cookie_domain: Option<String>,
pub cookie_path: String,
pub cookie_secure: bool,
pub cookie_http_only: bool,
pub cookie_same_site: SameSite,
pub ttl: Duration,
pub id_length: usize,
pub secret_key: Option<String>,
pub signed: bool,
}Expand description
Session 配置
定义 Session 的各种配置选项。
Fields§
Session Cookie 名称
Session Cookie 域
Session Cookie 路径
是否仅 HTTPS
是否 HttpOnly
SameSite 策略
ttl: DurationSession 过期时间
id_length: usizeSession ID 长度
secret_key: Option<String>签名密钥
signed: bool是否启用签名
Implementations§
Source§impl SessionConfig
impl SessionConfig
设置 Cookie 名称
设置 Cookie 域
设置 Cookie 路径
Sourcepub fn with_secure(self, secure: bool) -> Self
pub fn with_secure(self, secure: bool) -> Self
设置是否仅 HTTPS
Sourcepub fn with_http_only(self, http_only: bool) -> Self
pub fn with_http_only(self, http_only: bool) -> Self
设置是否 HttpOnly
Sourcepub fn with_same_site(self, same_site: SameSite) -> Self
pub fn with_same_site(self, same_site: SameSite) -> Self
设置 SameSite 策略
Sourcepub fn with_id_length(self, length: usize) -> Self
pub fn with_id_length(self, length: usize) -> Self
设置 Session ID 长度
Sourcepub fn with_secret_key(self, key: impl Into<String>) -> Self
pub fn with_secret_key(self, key: impl Into<String>) -> Self
设置签名密钥
生成 Cookie 字符串
Trait Implementations§
Source§impl Clone for SessionConfig
impl Clone for SessionConfig
Source§fn clone(&self) -> SessionConfig
fn clone(&self) -> SessionConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SessionConfig
impl Debug for SessionConfig
Auto Trait Implementations§
impl Freeze for SessionConfig
impl RefUnwindSafe for SessionConfig
impl Send for SessionConfig
impl Sync for SessionConfig
impl Unpin for SessionConfig
impl UnsafeUnpin for SessionConfig
impl UnwindSafe for SessionConfig
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
Mutably borrows from an owned value. Read more