format code
This commit is contained in:
parent
a6a0e1994d
commit
8180baae00
2 changed files with 15 additions and 11 deletions
|
@ -1,6 +1,6 @@
|
|||
use imap_codec::imap_types::core::NonEmptyVec;
|
||||
use imap_codec::imap_types::response::Capability;
|
||||
use imap_codec::imap_types::extensions::enable::{CapabilityEnable, Utf8Kind};
|
||||
use imap_codec::imap_types::response::Capability;
|
||||
use std::collections::HashSet;
|
||||
|
||||
fn capability_unselect() -> Capability<'static> {
|
||||
|
@ -32,7 +32,12 @@ impl Default for ServerCapability {
|
|||
|
||||
impl ServerCapability {
|
||||
pub fn to_vec(&self) -> NonEmptyVec<Capability<'static>> {
|
||||
self.0.iter().map(|v| v.clone()).collect::<Vec<_>>().try_into().unwrap()
|
||||
self.0
|
||||
.iter()
|
||||
.map(|v| v.clone())
|
||||
.collect::<Vec<_>>()
|
||||
.try_into()
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
|
|
|
@ -3,13 +3,13 @@ use std::sync::Arc;
|
|||
|
||||
use anyhow::{anyhow, bail, Result};
|
||||
use imap_codec::imap_types::command::{Command, CommandBody};
|
||||
use imap_codec::imap_types::core::{Atom, Literal, QuotedChar, NonEmptyVec};
|
||||
use imap_codec::imap_types::core::{Atom, Literal, NonEmptyVec, QuotedChar};
|
||||
use imap_codec::imap_types::datetime::DateTime;
|
||||
use imap_codec::imap_types::extensions::enable::CapabilityEnable;
|
||||
use imap_codec::imap_types::flag::{Flag, FlagNameAttribute};
|
||||
use imap_codec::imap_types::mailbox::{ListMailbox, Mailbox as MailboxCodec};
|
||||
use imap_codec::imap_types::response::{Code, CodeOther, Data};
|
||||
use imap_codec::imap_types::status::{StatusDataItem, StatusDataItemName};
|
||||
use imap_codec::imap_types::extensions::enable::CapabilityEnable;
|
||||
|
||||
use crate::imap::capability::{ClientCapability, ServerCapability};
|
||||
use crate::imap::command::{anystate, MailboxName};
|
||||
|
@ -68,9 +68,7 @@ pub async fn dispatch<'a>(
|
|||
} => ctx.append(mailbox, flags, date, message).await,
|
||||
|
||||
// rfc5161 ENABLE
|
||||
CommandBody::Enable { capabilities } => {
|
||||
ctx.enable(capabilities)
|
||||
},
|
||||
CommandBody::Enable { capabilities } => ctx.enable(capabilities),
|
||||
|
||||
// Collect other commands
|
||||
_ => anystate::wrong_state(ctx.req.tag.clone()),
|
||||
|
@ -518,16 +516,17 @@ impl<'a> AuthenticatedContext<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn enable(self, cap_enable: &NonEmptyVec<CapabilityEnable<'static>>) -> Result<(Response<'static>, flow::Transition)> {
|
||||
fn enable(
|
||||
self,
|
||||
cap_enable: &NonEmptyVec<CapabilityEnable<'static>>,
|
||||
) -> Result<(Response<'static>, flow::Transition)> {
|
||||
let mut response_builder = Response::build().to_req(self.req);
|
||||
let capabilities = self.client_capabilities.try_enable(cap_enable.as_ref());
|
||||
if capabilities.len() > 0 {
|
||||
response_builder = response_builder.data(Data::Enabled { capabilities });
|
||||
}
|
||||
Ok((
|
||||
response_builder
|
||||
.message("ENABLE completed")
|
||||
.ok()?,
|
||||
response_builder.message("ENABLE completed").ok()?,
|
||||
flow::Transition::None,
|
||||
))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue