From 184328ebcf100496d8b6df0cc570c773a2203a2e Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Tue, 9 Jan 2024 19:16:55 +0100 Subject: Optional Parameters with the SELECT/EXAMINE Commands See: https://datatracker.ietf.org/doc/html/rfc4466#section-2.4 --- src/imap/capability.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/imap/capability.rs') diff --git a/src/imap/capability.rs b/src/imap/capability.rs index d88673c..be1d4b6 100644 --- a/src/imap/capability.rs +++ b/src/imap/capability.rs @@ -1,4 +1,4 @@ -use imap_codec::imap_types::core::NonEmptyVec; +use imap_codec::imap_types::core::{Atom, NonEmptyVec}; use imap_codec::imap_types::extensions::enable::{CapabilityEnable, Utf8Kind}; use imap_codec::imap_types::response::Capability; use std::collections::HashSet; @@ -48,6 +48,7 @@ impl ServerCapability { } } +#[derive(Clone)] pub enum ClientStatus { NotSupportedByServer, Disabled, @@ -57,6 +58,13 @@ impl ClientStatus { pub fn is_enabled(&self) -> bool { matches!(self, Self::Enabled) } + + pub fn enable(&self) -> Self { + match self { + Self::Disabled => Self::Enabled, + other => other.clone(), + } + } } @@ -76,6 +84,14 @@ impl ClientCapability { } } + pub fn select_enable(&mut self, atoms: &[Atom]) { + for at in atoms.iter() { + if at.as_ref().to_uppercase() == "CONDSTORE" { + self.condstore = self.condstore.enable(); + } + } + } + pub fn try_enable( &mut self, caps: &[CapabilityEnable<'static>], -- cgit v1.2.3