diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2025-03-23 15:58:33 -0400 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2025-03-23 16:25:22 -0400 |
| commit | 2420f1e75d54a5f209b0267715f078a369d81eb1 (patch) | |
| tree | 20edd531a3f2f765a23fef8e7a508c91bc7dc294 /src/login/snapshot.rs | |
| parent | 7e15690d54ff849596401b43d163df9353062850 (diff) | |
Rename the `login` module to `user`.
Diffstat (limited to 'src/login/snapshot.rs')
| -rw-r--r-- | src/login/snapshot.rs | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/src/login/snapshot.rs b/src/login/snapshot.rs deleted file mode 100644 index 5c5dce0..0000000 --- a/src/login/snapshot.rs +++ /dev/null @@ -1,51 +0,0 @@ -use super::{ - Id, - event::{Created, Event}, -}; -use crate::name::Name; - -// This also implements FromRequestParts (see `./extract.rs`). As a result, it -// can be used as an extractor for endpoints that want to require login, or for -// endpoints that need to behave differently depending on whether the client is -// or is not logged in. -#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize)] -pub struct Login { - pub id: Id, - pub name: Name, - // The omission of the hashed password is deliberate, to minimize the - // chance that it ends up tangled up in debug output or in some other chunk - // of logic elsewhere. -} - -impl Login { - // Two reasons for this allow: - // - // 1. This is used to collect streams using a fold, below, which requires a type - // consistent with the fold, and - // 2. It's also consistent with the other history state machine types. - #[allow(clippy::unnecessary_wraps)] - fn apply(state: Option<Self>, event: Event) -> Option<Self> { - match (state, event) { - (None, Event::Created(event)) => Some(event.into()), - (state, event) => panic!("invalid message event {event:#?} for state {state:#?}"), - } - } -} - -impl FromIterator<Event> for Option<Login> { - fn from_iter<I: IntoIterator<Item = Event>>(events: I) -> Self { - events.into_iter().fold(None, Login::apply) - } -} - -impl From<&Created> for Login { - fn from(event: &Created) -> Self { - event.login.clone() - } -} - -impl From<Created> for Login { - fn from(event: Created) -> Self { - event.login - } -} |
