pub struct KeyManager { /* private fields */ }Expand description
密钥管理器(支持轮换)
维护一个当前活跃密钥和最多 3 个历史密钥(用于解密过渡期),
支持按时间间隔自动轮换检查。所有字段使用 RwLock 保护,可安全跨线程共享。
Implementations§
Source§impl KeyManager
impl KeyManager
Sourcepub fn with_rotation_interval(self, interval: Duration) -> Self
pub fn with_rotation_interval(self, interval: Duration) -> Self
设置轮换间隔
Sourcepub fn needs_rotation(&self) -> bool
pub fn needs_rotation(&self) -> bool
检查是否需要轮换
Sourcepub fn current_key(&self) -> VersionedKey
pub fn current_key(&self) -> VersionedKey
获取当前密钥
Sourcepub fn key_by_version(&self, version: u32) -> Option<VersionedKey>
pub fn key_by_version(&self, version: u32) -> Option<VersionedKey>
按版本查找密钥
Sourcepub fn previous_count(&self) -> usize
pub fn previous_count(&self) -> usize
返回保留的旧密钥数量
Auto Trait Implementations§
impl !Freeze for KeyManager
impl RefUnwindSafe for KeyManager
impl Send for KeyManager
impl Sync for KeyManager
impl Unpin for KeyManager
impl UnsafeUnpin for KeyManager
impl UnwindSafe for KeyManager
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