summaryrefslogtreecommitdiff
path: root/src/user/history.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/history.rs')
-rw-r--r--src/user/history.rs22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/user/history.rs b/src/user/history.rs
index f58e9c7..7c06a2d 100644
--- a/src/user/history.rs
+++ b/src/user/history.rs
@@ -2,7 +2,10 @@ use super::{
User,
event::{Created, Event},
};
-use crate::event::{Instant, Sequence};
+use crate::{
+ event::{Instant, Sequence},
+ login::Login,
+};
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct History {
@@ -10,6 +13,21 @@ pub struct History {
pub created: Instant,
}
+// Lifecycle interface
+impl History {
+ pub fn begin(login: &Login, created: Instant) -> Self {
+ let Login { id, name } = login.clone();
+
+ Self {
+ user: User {
+ id: id.into(),
+ name,
+ },
+ created,
+ }
+ }
+}
+
// State interface
impl History {
pub fn as_of<S>(&self, sequence: S) -> Option<User>
@@ -32,7 +50,7 @@ impl History {
.into()
}
- pub fn events(&self) -> impl Iterator<Item = Event> + use<> {
+ pub fn events(&self) -> impl Iterator<Item = Event> + Clone + use<> {
[self.created()].into_iter()
}
}