pub struct KeyManager { /* private fields */ }Expand description
Key manager (supports rotation).
Maintains a current active key and at most 3 historical keys (for the
decryption transition period), and supports automatic rotation checks at
a fixed time interval. All fields are protected by RwLock and can be
safely shared across threads.
Implementations§
Source§impl KeyManager
impl KeyManager
Sourcepub fn new(initial_key: Vec<u8>) -> Self
pub fn new(initial_key: Vec<u8>) -> Self
Create a key manager with the given initial key (version numbering starts at 1).
Sourcepub fn with_rotation_interval(self, interval: Duration) -> Self
pub fn with_rotation_interval(self, interval: Duration) -> Self
Set the rotation interval.
Sourcepub fn needs_rotation(&self) -> bool
pub fn needs_rotation(&self) -> bool
Check whether rotation is needed.
Sourcepub fn current_key(&self) -> VersionedKey
pub fn current_key(&self) -> VersionedKey
Get the current key.
Sourcepub fn key_by_version(&self, version: u32) -> Option<VersionedKey>
pub fn key_by_version(&self, version: u32) -> Option<VersionedKey>
Look up a key by version.
Sourcepub fn previous_count(&self) -> usize
pub fn previous_count(&self) -> usize
Return the number of retained old keys.
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