ipmail 0.1.0

Rust implementation of SP-centric decentralized instant message synchronization protocol(DIMSP)
Documentation
pub struct Percentage {
    current: usize,
    total: usize,
}

impl Percentage {
    pub fn new(start: usize, total: usize) -> Self {
        Self {
            current: start,
            total,
        }
    }

    pub fn total(&self) -> usize {
        self.total
    }

    pub fn current(&self) -> usize {
        self.current
    }

    pub fn advance(&mut self, steps: usize) -> usize {
        self.current += steps;

        if self.current > self.total {
            self.current = self.total;
        }

        self.current
    }

    pub fn advance_to(&mut self, to: usize) -> usize {
        if self.total < to {
            self.current = self.total
        } else {
            self.current = to;
        }

        self.current
    }

    pub fn is_complete(&self) -> bool {
        self.current == self.total
    }
}