Import upstream v0.16.22, stripped
Upstream commit: 474dd0229cb20cf513036619781ed97bd8073c3f Enterprise-only files removed or emptied: 63 Enterprise-only snippets removed: 117 in 50 files Dangling module declarations removed: 5 Cargo edits turning enterprise off: 14 Verification: clean Enterprise feature gates left for rebuilt features: 19 in 18 files Produced by tools/fork/strip.py. The full report is in docs/fork/strip-reports/ on main.
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020 Stalwart Labs LLC <[email protected]>
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
|
||||
*/
|
||||
|
||||
use compact_str::ToCompactString;
|
||||
|
||||
use crate::{
|
||||
Command,
|
||||
protocol::delete,
|
||||
receiver::{Request, bad},
|
||||
utf7::utf7_maybe_decode,
|
||||
};
|
||||
|
||||
impl Request<Command> {
|
||||
pub fn parse_delete(self, is_utf8: bool) -> trc::Result<delete::Arguments> {
|
||||
match self.tokens.len() {
|
||||
1 => Ok(delete::Arguments {
|
||||
mailbox_name: utf7_maybe_decode(
|
||||
self.tokens
|
||||
.into_iter()
|
||||
.next()
|
||||
.unwrap()
|
||||
.unwrap_string()
|
||||
.map_err(|v| bad(self.tag.to_compact_string(), v))?,
|
||||
is_utf8,
|
||||
),
|
||||
tag: self.tag,
|
||||
}),
|
||||
0 => Err(self.into_error("Missing mailbox name.")),
|
||||
_ => Err(self.into_error("Too many arguments.")),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{protocol::delete, receiver::Receiver};
|
||||
|
||||
#[test]
|
||||
fn parse_delete() {
|
||||
let mut receiver = Receiver::new();
|
||||
|
||||
for (command, arguments) in [
|
||||
(
|
||||
"A142 DELETE INBOX\r\n",
|
||||
delete::Arguments {
|
||||
mailbox_name: "INBOX".into(),
|
||||
tag: "A142".into(),
|
||||
},
|
||||
),
|
||||
(
|
||||
"A142 DELETE \"my funky mailbox\"\r\n",
|
||||
delete::Arguments {
|
||||
mailbox_name: "my funky mailbox".into(),
|
||||
tag: "A142".into(),
|
||||
},
|
||||
),
|
||||
] {
|
||||
assert_eq!(
|
||||
receiver
|
||||
.parse(&mut command.as_bytes().iter())
|
||||
.unwrap()
|
||||
.parse_delete(true)
|
||||
.unwrap(),
|
||||
arguments
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user