aboutsummaryrefslogtreecommitdiff
path: root/src/imap/flow.rs
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2022-06-20 18:09:20 +0200
committerQuentin Dufour <quentin@deuxfleurs.fr>2022-06-20 18:09:20 +0200
commitca4c2e7505f28acad688705d45cc5c5dca1799c3 (patch)
tree6820ad27dfdaa5e51e2f296832d75a4a9a6678ae /src/imap/flow.rs
parent5dd5ae8bcd6f88703bc483d7f8d5882fefad4e7e (diff)
downloadaerogramme-ca4c2e7505f28acad688705d45cc5c5dca1799c3.tar.gz
aerogramme-ca4c2e7505f28acad688705d45cc5c5dca1799c3.zip
WIP refactor
Diffstat (limited to 'src/imap/flow.rs')
-rw-r--r--src/imap/flow.rs17
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(())
}