diff options
Diffstat (limited to 'src/imap/flow.rs')
-rw-r--r-- | src/imap/flow.rs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/imap/flow.rs b/src/imap/flow.rs index 8ba75bc..6d8b581 100644 --- a/src/imap/flow.rs +++ b/src/imap/flow.rs @@ -1,3 +1,6 @@ + + +use crate::login::Credentials; use crate::mailbox::Mailbox; pub struct User { @@ -19,9 +22,9 @@ pub enum Error { // https://datatracker.ietf.org/doc/html/rfc3501#page-13 impl State { pub fn authenticate(&mut self, user: User) -> Result<(), Error> { - self = match state { + self = match self { State::NotAuthenticated => State::Authenticated(user), - _ => return Err(ForbiddenTransition), + _ => return Err(Error::ForbiddenTransition), }; Ok(()) } @@ -32,17 +35,17 @@ impl State { } pub fn select(&mut self, mailbox: Mailbox) -> Result<(), Error> { - self = match state { + self = match self { State::Authenticated(user) => State::Selected(user, mailbox), - _ => return Err(ForbiddenTransition), + _ => return Err(Error::ForbiddenTransition), }; Ok(()) } - pub fn unselect(state: State) -> Result<(), Error> { - self = match state { + pub fn unselect(&mut self) -> Result<(), Error> { + self = match self { State::Selected(user, _) => State::Authenticated(user), - _ => return Err(ForbiddenTransition), + _ => return Err(Error::ForbiddenTransition), }; Ok(()) } |