This commit is contained in:
Michael Zhang 2021-08-08 18:53:21 -05:00
parent aae287c8b1
commit 49ffb4d7ce
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
7 changed files with 33 additions and 24 deletions

36
Cargo.lock generated
View file

@ -266,24 +266,6 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]]
name = "imap"
version = "0.1.0"
dependencies = [
"anyhow",
"async-trait",
"bitflags",
"bytes",
"derive_builder",
"futures",
"log",
"nom",
"tokio",
"tokio-rustls",
"tokio-util",
"webpki-roots",
]
[[package]] [[package]]
name = "instant" name = "instant"
version = "0.1.10" version = "0.1.10"
@ -411,6 +393,24 @@ version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56"
[[package]]
name = "panorama-imap"
version = "0.0.2"
dependencies = [
"anyhow",
"async-trait",
"bitflags",
"bytes",
"derive_builder",
"futures",
"log",
"nom",
"tokio",
"tokio-rustls",
"tokio-util",
"webpki-roots",
]
[[package]] [[package]]
name = "parking_lot" name = "parking_lot"
version = "0.11.1" version = "0.11.1"

View file

@ -1,6 +1,6 @@
[package] [package]
name = "imap" name = "panorama-imap"
version = "0.1.0" version = "0.0.2"
edition = "2018" edition = "2018"
[[bin]] [[bin]]

View file

@ -1,5 +1,5 @@
use anyhow::Result; use anyhow::Result;
use imap::client::ConfigBuilder; use panorama_imap::client::ConfigBuilder;
#[tokio::main] #[tokio::main]
async fn main() -> Result<()> { async fn main() -> Result<()> {

View file

@ -5,6 +5,11 @@ use nom::{
Err, IResult, InputIter, Needed, Parser, Slice, Err, IResult, InputIter, Needed, Parser, Slice,
}; };
/// `sep_list!(t, d)` represents `t *(d t)` and automatically collapses it into `Vec<T>`.
///
/// Also `sep_list!(?t, d)` represents `[t *(d t)]` and will default to an empty vec.
///
/// If `d` is not passed then it defaults to `SP`.
macro_rules! sep_list { macro_rules! sep_list {
($t:expr) => { ($t:expr) => {
map( map(
@ -44,8 +49,10 @@ macro_rules! sep_list {
}; };
} }
/// Always fails, used as a no-op.
pub fn never<I, O>(i: I) -> IResult<I, O> { Err(Err::Error(Error::new(i, ErrorKind::Not))) } pub fn never<I, O>(i: I) -> IResult<I, O> { Err(Err::Error(Error::new(i, ErrorKind::Not))) }
/// Skip the part of the input matched by the given parser.
pub fn skip<E, F, I, O>(mut f: F) -> impl FnMut(I) -> IResult<I, (), E> pub fn skip<E, F, I, O>(mut f: F) -> impl FnMut(I) -> IResult<I, (), E>
where where
I: Clone, I: Clone,
@ -57,6 +64,7 @@ where
} }
} }
/// Same as nom satisfy, but operates on `&[u8]` instead of `&str`.
pub fn satisfy<F, I, E, T>(f: F) -> impl Fn(I) -> IResult<I, T, E> pub fn satisfy<F, I, E, T>(f: F) -> impl Fn(I) -> IResult<I, T, E>
where where
I: Slice<RangeFrom<usize>> + InputIter<Item = T>, I: Slice<RangeFrom<usize>> + InputIter<Item = T>,
@ -71,6 +79,7 @@ where
} }
} }
/// Match a single byte exactly.
pub fn byte<I, E: ParseError<I>>(b: u8) -> impl Fn(I) -> IResult<I, u8, E> pub fn byte<I, E: ParseError<I>>(b: u8) -> impl Fn(I) -> IResult<I, u8, E>
where where
I: Slice<RangeFrom<usize>> + InputIter<Item = u8>, I: Slice<RangeFrom<usize>> + InputIter<Item = u8>,

View file

@ -1 +1 @@
//! Grammar from https://datatracker.ietf.org/doc/html/rfc2177#section-4 //! Grammar from <https://datatracker.ietf.org/doc/html/rfc2177#section-4>

View file

@ -1,4 +1,4 @@
//! Grammar from https://tools.ietf.org/html/rfc2234#section-6.1 //! Grammar from <https://tools.ietf.org/html/rfc2234#section-6.1>
use nom::{branch::alt, character::streaming::anychar, multi::many0, sequence::pair}; use nom::{branch::alt, character::streaming::anychar, multi::many0, sequence::pair};

View file

@ -1,4 +1,4 @@
//! Grammar from https://datatracker.ietf.org/doc/html/rfc3501#section-9 //! Grammar from <https://datatracker.ietf.org/doc/html/rfc3501#section-9>
use std::borrow::Cow; use std::borrow::Cow;