pub struct KeyRotationManager { /* private fields */ }Expand description
密钥轮换管理器
管理多个版本的密钥,支持:
- 轮换生成新版本密钥
- 用最新密钥签名
- 用任意历史密钥验证(向后兼容)
- 自动淘汰过期密钥
Implementations§
Source§impl KeyRotationManager
impl KeyRotationManager
Sourcepub fn with_initial_key(key: Vec<u8>) -> Self
pub fn with_initial_key(key: Vec<u8>) -> Self
初始化首个密钥版本
Sourcepub fn rotate_key(&mut self, new_key: Vec<u8>) -> u32
pub fn rotate_key(&mut self, new_key: Vec<u8>) -> u32
轮换到新密钥,返回新版本号
Sourcepub fn current_version(&self) -> u32
pub fn current_version(&self) -> u32
返回当前密钥版本号
Sourcepub fn version_count(&self) -> usize
pub fn version_count(&self) -> usize
返回保留的密钥版本数量
Sourcepub fn key_created_at(&self, version: u32) -> Option<u64>
pub fn key_created_at(&self, version: u32) -> Option<u64>
返回指定版本密钥的创建时间(Unix 秒),不存在返回 None
Auto Trait Implementations§
impl Freeze for KeyRotationManager
impl RefUnwindSafe for KeyRotationManager
impl Send for KeyRotationManager
impl Sync for KeyRotationManager
impl Unpin for KeyRotationManager
impl UnsafeUnpin for KeyRotationManager
impl UnwindSafe for KeyRotationManager
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