diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2024-03-08 09:55:33 +0100 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2024-03-08 09:55:33 +0100 |
commit | 11462f80c4ae25696c7436ed7aacb92074d7e911 (patch) | |
tree | 333677df5ea981b0e1468b43fc00df9d242ad4fa /aero-proto/src/imap/command/anystate.rs | |
parent | 1edf0b15ecaa73d55bb72c6f3c6e25d4f231f322 (diff) | |
download | aerogramme-11462f80c4ae25696c7436ed7aacb92074d7e911.tar.gz aerogramme-11462f80c4ae25696c7436ed7aacb92074d7e911.zip |
Re-enable proto
Diffstat (limited to 'aero-proto/src/imap/command/anystate.rs')
-rw-r--r-- | aero-proto/src/imap/command/anystate.rs | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/aero-proto/src/imap/command/anystate.rs b/aero-proto/src/imap/command/anystate.rs new file mode 100644 index 0000000..718ba3f --- /dev/null +++ b/aero-proto/src/imap/command/anystate.rs @@ -0,0 +1,54 @@ +use anyhow::Result; +use imap_codec::imap_types::core::Tag; +use imap_codec::imap_types::response::Data; + +use crate::imap::capability::ServerCapability; +use crate::imap::flow; +use crate::imap::response::Response; + +pub(crate) fn capability( + tag: Tag<'static>, + cap: &ServerCapability, +) -> Result<(Response<'static>, flow::Transition)> { + let res = Response::build() + .tag(tag) + .message("Server capabilities") + .data(Data::Capability(cap.to_vec())) + .ok()?; + + Ok((res, flow::Transition::None)) +} + +pub(crate) fn noop_nothing(tag: Tag<'static>) -> Result<(Response<'static>, flow::Transition)> { + Ok(( + Response::build().tag(tag).message("Noop completed.").ok()?, + flow::Transition::None, + )) +} + +pub(crate) fn logout() -> Result<(Response<'static>, flow::Transition)> { + Ok((Response::bye()?, flow::Transition::Logout)) +} + +pub(crate) fn not_implemented<'a>( + tag: Tag<'a>, + what: &str, +) -> Result<(Response<'a>, flow::Transition)> { + Ok(( + Response::build() + .tag(tag) + .message(format!("Command not implemented {}", what)) + .bad()?, + flow::Transition::None, + )) +} + +pub(crate) fn wrong_state(tag: Tag<'static>) -> Result<(Response<'static>, flow::Transition)> { + Ok(( + Response::build() + .tag(tag) + .message("Command not authorized in this state") + .bad()?, + flow::Transition::None, + )) +} |