mirror of
https://git.meli.delivery/meli/meli
synced 2024-10-30 21:20:34 +00:00
Run cargo fmt
This commit is contained in:
parent
2bdb41311e
commit
a0602274f8
@ -70,11 +70,7 @@ named!(
|
||||
named!(
|
||||
my_flags<Flag>,
|
||||
do_parse!(
|
||||
flags:
|
||||
separated_nonempty_list!(
|
||||
tag!(" "),
|
||||
preceded!(tag!("\\"), is_not!(")"))
|
||||
)
|
||||
flags: separated_nonempty_list!(tag!(" "), preceded!(tag!("\\"), is_not!(")")))
|
||||
>> ({
|
||||
let mut ret = Flag::default();
|
||||
for f in flags {
|
||||
@ -108,7 +104,7 @@ named!(
|
||||
|
||||
/*
|
||||
*
|
||||
* * 1 FETCH (FLAGS (\Seen) UID 1 RFC822.HEADER {5224}
|
||||
* "* 1 FETCH (FLAGS (\Seen) UID 1 RFC822.HEADER {5224}
"
|
||||
*/
|
||||
named!(
|
||||
pub uid_fetch_response<Vec<(usize, Option<Flag>, &[u8])>>,
|
||||
@ -250,7 +246,6 @@ named!(
|
||||
>> tag: take_until!("\r\n")
|
||||
>> tag!("\r\n")
|
||||
>> ({
|
||||
|
||||
use UntaggedResponse::*;
|
||||
match tag {
|
||||
b"EXPUNGE" => Some(Expunge(num)),
|
||||
@ -265,7 +260,6 @@ named!(
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
named!(
|
||||
pub search_results<Vec<usize>>,
|
||||
alt_complete!(do_parse!( tag!("* SEARCH")
|
||||
@ -284,7 +278,6 @@ named!(
|
||||
do_parse!(tag!("* SEARCH\r\n") >> ({ &b""[0..] })))
|
||||
);
|
||||
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum SelectResponse {
|
||||
Ok(SelectResponseOk),
|
||||
@ -340,15 +333,23 @@ pub fn select_response(input: &str) -> IResult<&str, SelectResponse> {
|
||||
} else if l.starts_with("* ") && l.ends_with(" RECENT") {
|
||||
ret.recent = usize::from_str(&l["* ".len()..l.len() - " RECENT".len()]).unwrap();
|
||||
} else if l.starts_with("* FLAGS (") {
|
||||
ret.flags = flags(&l["* FLAGS (".len()..l.len() - ")".len()]).to_full_result().unwrap();
|
||||
ret.flags = flags(&l["* FLAGS (".len()..l.len() - ")".len()])
|
||||
.to_full_result()
|
||||
.unwrap();
|
||||
} else if l.starts_with("* OK [UNSEEN ") {
|
||||
ret.unseen = usize::from_str(&l["* OK [UNSEEN ".len()..l.find(']').unwrap()]).unwrap();
|
||||
ret.unseen =
|
||||
usize::from_str(&l["* OK [UNSEEN ".len()..l.find(']').unwrap()]).unwrap();
|
||||
} else if l.starts_with("* OK [UIDVALIDITY ") {
|
||||
ret.uidvalidity = usize::from_str(&l["* OK [UIDVALIDITY ".len()..l.find(']').unwrap()]).unwrap();
|
||||
ret.uidvalidity =
|
||||
usize::from_str(&l["* OK [UIDVALIDITY ".len()..l.find(']').unwrap()]).unwrap();
|
||||
} else if l.starts_with("* OK [UIDNEXT ") {
|
||||
ret.uidnext = usize::from_str(&l["* OK [UIDNEXT ".len()..l.find(']').unwrap()]).unwrap();
|
||||
ret.uidnext =
|
||||
usize::from_str(&l["* OK [UIDNEXT ".len()..l.find(']').unwrap()]).unwrap();
|
||||
} else if l.starts_with("* OK [PERMANENTFLAGS (") {
|
||||
ret.permanentflags = flags(&l["* OK [PERMANENTFLAGS (".len()..l.find(')').unwrap()]).to_full_result().unwrap();
|
||||
ret.permanentflags =
|
||||
flags(&l["* OK [PERMANENTFLAGS (".len()..l.find(')').unwrap()])
|
||||
.to_full_result()
|
||||
.unwrap();
|
||||
} else if !l.is_empty() {
|
||||
debug!("select response: {}", l);
|
||||
}
|
||||
@ -362,7 +363,9 @@ pub fn select_response(input: &str) -> IResult<&str, SelectResponse> {
|
||||
} else if l.starts_with("* ") && l.ends_with(" RECENT") {
|
||||
ret.recent = usize::from_str(&l["* ".len()..l.len() - " RECENT".len()]).unwrap();
|
||||
} else if l.starts_with("* FLAGS (") {
|
||||
ret.flags = flags(&l["* FLAGS (".len()..l.len() - ")".len()]).to_full_result().unwrap();
|
||||
ret.flags = flags(&l["* FLAGS (".len()..l.len() - ")".len()])
|
||||
.to_full_result()
|
||||
.unwrap();
|
||||
} else if !l.is_empty() {
|
||||
debug!("select response: {}", l);
|
||||
}
|
||||
@ -419,7 +422,6 @@ pub fn byte_flags(input: &[u8]) -> IResult<&[u8], Flag> {
|
||||
IResult::Done(rest, ret) => IResult::Done(rest.as_bytes(), ret),
|
||||
IResult::Error(e) => IResult::Error(e),
|
||||
IResult::Incomplete(e) => IResult::Incomplete(e),
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -514,23 +516,6 @@ named!(
|
||||
})
|
||||
));
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_envelope() {
|
||||
// FIXME add a proper test
|
||||
/*
|
||||
use std::io::Read;
|
||||
let mut buffer: Vec<u8> = Vec::new();
|
||||
let _ = std::fs::File::open("/tmp/a").unwrap().read_to_end(&mut buffer);
|
||||
debug!(envelope(&buffer));
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
/* Helper to build StrBuilder for Address structs */
|
||||
macro_rules! str_builder {
|
||||
($offset:expr, $length:expr) => {
|
||||
@ -538,7 +523,7 @@ macro_rules! str_builder {
|
||||
offset: $offset,
|
||||
length: $length,
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Parse a list of addresses in the format of the ENVELOPE structure
|
||||
@ -592,7 +577,8 @@ pub fn quoted(input: &[u8]) -> IResult<&[u8], Vec<u8>> {
|
||||
|
||||
let mut i = 1;
|
||||
while i < input.len() {
|
||||
if input[i] == b'\"' { //&& input[i - 1] != b'\\' {
|
||||
if input[i] == b'\"' {
|
||||
//&& input[i - 1] != b'\\' {
|
||||
return match crate::email::parser::phrase(&input[1..i]) {
|
||||
IResult::Done(_, out) => IResult::Done(&input[i + 1..], out),
|
||||
e => e,
|
||||
@ -623,4 +609,3 @@ named!(
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user