rotate_backup 0.1.2

Rotate you backups easily
Documentation
use super::*;
use crate::partition::PartitionExponentBase;

#[derive(Default)]
#[cfg_attr(feature = "cli", derive(clap::Args))]
/// Debug the partition algorithm
///
/// Prints the partitions and the range for each partition.
pub struct DebugCommand {
    /// Base to use to compute exponential window sizes
    ///
    /// Note: Must be greater than 1.0
    /// Defaults to: 1.1
    #[cfg_attr(feature = "cli", arg(short, long))]
    pub base: Option<PartitionExponentBase>,

    /// Number of partition to debug
    pub partition_count: usize,
}

/// Returns the start of each partition
pub fn debug_partitions(base: PartitionExponentBase, count: usize) -> Vec<u64> {
    (0..count)
        .map(|i| PartitionSize::exponential(base, PartitionIndex(i as u32)))
        .fold((vec![0u64], 0u64), |(mut result, mut cumulated), size| {
            cumulated += size.0.get();
            result.push(cumulated);
            (result, cumulated)
        })
        .0
}