Skip to main content

RotationRequest

Struct RotationRequest 

Source
pub struct RotationRequest {
    pub to_version: i32,
    pub batch_size: u32,
    pub after_id: Option<Uuid>,
}
Expand description

One batch of a key rotation.

Rotation is driven batch by batch by the caller rather than in one long call, so that a rotation can be watched, interrupted, and resumed.

§Examples

use ironflow_store::entities::RotationRequest;

// Start from the beginning of the stock.
let first = RotationRequest::new(2);
assert!(first.after_id.is_none());

// Continue after the last secret seen.
let next = first.clone().after(uuid::Uuid::now_v7());
assert!(next.after_id.is_some());

Fields§

§to_version: i32

Key version every secret in the batch is re-encrypted with.

§batch_size: u32

How many secrets to process, clamped to [1, MAX_ROTATION_BATCH_SIZE].

§after_id: Option<Uuid>

Resume after this secret ID. None starts from the beginning.

The cursor is what keeps the rotation moving forward when a secret cannot be decrypted: a failed row is never served again.

Implementations§

Source§

impl RotationRequest

Source

pub fn new(to_version: i32) -> Self

A request for the first batch, with the default batch size.

§Examples
use ironflow_store::entities::{RotationRequest, DEFAULT_ROTATION_BATCH_SIZE};

let req = RotationRequest::new(2);
assert_eq!(req.to_version, 2);
assert_eq!(req.batch_size, DEFAULT_ROTATION_BATCH_SIZE);
Source

pub fn with_batch_size(self, batch_size: u32) -> Self

Set the batch size.

§Examples
use ironflow_store::entities::RotationRequest;

let req = RotationRequest::new(2).with_batch_size(10);
assert_eq!(req.batch_size, 10);
Source

pub fn after(self, id: Uuid) -> Self

Resume after a given secret ID.

§Examples
use ironflow_store::entities::RotationRequest;
use uuid::Uuid;

let id = Uuid::now_v7();
let req = RotationRequest::new(2).after(id);
assert_eq!(req.after_id, Some(id));
Source

pub fn effective_batch_size(&self) -> u32

The batch size clamped to the allowed range.

§Examples
use ironflow_store::entities::{RotationRequest, MAX_ROTATION_BATCH_SIZE};

assert_eq!(RotationRequest::new(2).with_batch_size(0).effective_batch_size(), 1);
assert_eq!(
    RotationRequest::new(2).with_batch_size(99_999).effective_batch_size(),
    MAX_ROTATION_BATCH_SIZE
);

Trait Implementations§

Source§

impl Clone for RotationRequest

Source§

fn clone(&self) -> RotationRequest

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RotationRequest

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.