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
43
44
45
46
47
48
49
use async_trait::async_trait;
use futures::io::AsyncRead;
use crate::Identifier;
#[async_trait(?Send)]
pub trait LogEntry: 'static + Clone + std::fmt::Debug + Send + Sync + Unpin {
type Id: Identifier;
type Reader: std::io::Read;
async fn from_reader<R: AsyncRead + Unpin>(read: R) -> Result<Self, crate::error::BoxError>;
fn size(&self) -> usize;
fn to_reader(&self) -> Self::Reader;
fn id(&self) -> Self::Id;
}
#[derive(Debug)]
pub struct LogKeeping {
pub(crate) logs_kept: usize,
pub(crate) entry_limit: usize,
}
impl Default for LogKeeping {
fn default() -> Self {
Self {
logs_kept: 5,
entry_limit: 1024,
}
}
}