跳到主要内容

StoresServerSessions

特性 StoresServerSessions 

Source
pub trait StoresServerSessions:
    Debug
    + Send
    + Sync {
    // Required methods
    fn put(&self, key: Vec<u8>, value: Vec<u8>) -> bool;
    fn get(&self, key: &[u8]) -> Option<Vec<u8>>;
    fn take(&self, key: &[u8]) -> Option<Vec<u8>>;
    fn can_cache(&self) -> bool;
}
展开描述

A trait 用于 the ability 到 store server session data.

此 keys 并 values are opaque.

Inserted keys are randomly chosen by the library 并 have no internal structure (in other words, you may rely on all bits being uniformly random)。 Queried keys are untrusted data.

Both the keys 并 values should be treated as highly sensitive data, containing enough 密钥材料 到 break all security of the corresponding sessions.

实现可以是有损的(即可能遗忘 键值对),不会带来任何负面安全后果。

However, note that take must reliably delete 一个 returned value. If it does not, there may be security consequences.

puttake are mutating operations; this isn’t expressed in the type system 到 allow implementations freedom in how 到 achieve interior mutability. Mutex 是 common choice.

必需方法§

Source

fn put(&self, key: Vec<u8>, value: Vec<u8>) -> bool

Store session secrets encoded in value against key, overwrites any existing value against key。 Returns true 则返回 true。

Source

fn get(&self, key: &[u8]) -> Option<Vec<u8>>

Find 一个 value with the given key。 Return it, 或 None if it doesn’t exist.

Source

fn take(&self, key: &[u8]) -> Option<Vec<u8>>

Find 一个 value with the given key。 Return it 并 delete it; 或 None if it doesn’t exist.

Source

fn can_cache(&self) -> bool

存储器是否可以缓存另一个会话。这用来向客户端指示 whether their session can be resumed; the implementation is not required 到 remember 一个 session even if it returns true here.

实现者§