pub struct KeyRotationState {
pub generation: u64,
pub established_at: Instant,
pub max_lifetime: Duration,
pub grace_period: Duration,
pub rotating: bool,
}Expand description
Key rotation state for a mesh connection.
Fields§
§generation: u64Current key generation number.
established_at: InstantWhen the current key was established.
max_lifetime: DurationMaximum key lifetime before rotation.
grace_period: DurationGrace period: old key accepted during transition.
rotating: boolWhether rotation is in progress.
Implementations§
Source§impl KeyRotationState
impl KeyRotationState
Sourcepub fn new(max_lifetime: Duration, grace_period: Duration) -> Self
pub fn new(max_lifetime: Duration, grace_period: Duration) -> Self
Create a new key rotation state at generation 0.
Sourcepub fn needs_rotation(&self) -> bool
pub fn needs_rotation(&self) -> bool
Check if key rotation is needed based on elapsed lifetime.
Sourcepub fn begin_rotation(&mut self)
pub fn begin_rotation(&mut self)
Start key rotation (marks as in-progress).
Sourcepub fn complete_rotation(&mut self)
pub fn complete_rotation(&mut self)
Complete key rotation, advancing to the next generation.
Sourcepub fn old_key_valid(&self) -> bool
pub fn old_key_valid(&self) -> bool
Check if the old key (previous generation) is still valid. True during active rotation or within the grace period.
Trait Implementations§
Source§impl Clone for KeyRotationState
impl Clone for KeyRotationState
Auto Trait Implementations§
impl Freeze for KeyRotationState
impl RefUnwindSafe for KeyRotationState
impl Send for KeyRotationState
impl Sync for KeyRotationState
impl Unpin for KeyRotationState
impl UnsafeUnpin for KeyRotationState
impl UnwindSafe for KeyRotationState
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more