fetsig/interface/
new_dirty.rs

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
use std::ops::{Deref, DerefMut};

pub trait Inner<E>
where
    Self: Deref<Target = E> + DerefMut,
{
    #[must_use]
    fn from_inner(inner: E) -> Self;

    #[must_use]
    fn into_inner(self) -> E
    where
        Self: Sized;

    fn inner(&self) -> &E {
        self.deref()
    }
}

pub trait New {
    fn is_new(&self) -> bool;

    #[must_use]
    fn with_new(self) -> Self
    where
        Self: Sized;

    #[must_use]
    fn with_existing(self) -> Self
    where
        Self: Sized;
}

pub trait Dirty {
    fn is_dirty(&self) -> bool;

    fn take_dirty(&mut self) -> bool;

    #[must_use]
    fn with_dirty(self) -> Self
    where
        Self: Sized;

    fn mark_as_dirty(&mut self);
}