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.
put 并 take are mutating operations; this isn’t expressed
in the type system 到 allow implementations freedom in
how 到 achieve interior mutability. Mutex 是 common
choice.
必需方法§
Sourcefn put(&self, key: Vec<u8>, value: Vec<u8>) -> bool
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。