summaryrefslogtreecommitdiff
path: root/src/status.rs
blob: 6874e882b9357beca03774140e84234f08d16f94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use crate::error::EntryError;
use std::fmt;

#[derive(Debug)]
pub struct PullStatus {
    count: usize,
    errors: Vec<EntryError>,
}

impl PullStatus {
    pub fn new(count: usize, errors: Vec<EntryError>) -> Self {
        Self { count, errors }
    }
}

impl fmt::Display for PullStatus {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(
            f,
            "pulled {} entries with {} errors",
            self.count,
            self.errors.len()
        )
    }
}

#[derive(Debug)]
pub struct StoreStatus {
    count: usize,
}

impl StoreStatus {
    pub fn new(count: usize) -> Self {
        Self { count }
    }
}

impl fmt::Display for StoreStatus {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "stored {} feeds", self.count,)
    }
}