From 49ffb4d7ce9b48dc967159beb2cb542ccfee6409 Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Sun, 8 Aug 2021 18:53:21 -0500 Subject: [PATCH] upd --- Cargo.lock | 36 ++++++++++++++++++------------------ imap/Cargo.toml | 4 ++-- imap/bin/greenmail_test.rs | 2 +- imap/src/proto/parsers.rs | 9 +++++++++ imap/src/proto/rfc2177.rs | 2 +- imap/src/proto/rfc2234.rs | 2 +- imap/src/proto/rfc3501.rs | 2 +- 7 files changed, 33 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aeb5bf9..01e03a6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -266,24 +266,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" 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]] name = "instant" version = "0.1.10" @@ -411,6 +393,24 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" 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]] name = "parking_lot" version = "0.11.1" diff --git a/imap/Cargo.toml b/imap/Cargo.toml index dabf0a7..1207398 100644 --- a/imap/Cargo.toml +++ b/imap/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "imap" -version = "0.1.0" +name = "panorama-imap" +version = "0.0.2" edition = "2018" [[bin]] diff --git a/imap/bin/greenmail_test.rs b/imap/bin/greenmail_test.rs index 87aa1d3..0a7bbed 100644 --- a/imap/bin/greenmail_test.rs +++ b/imap/bin/greenmail_test.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use imap::client::ConfigBuilder; +use panorama_imap::client::ConfigBuilder; #[tokio::main] async fn main() -> Result<()> { diff --git a/imap/src/proto/parsers.rs b/imap/src/proto/parsers.rs index df6842f..c7bea8e 100644 --- a/imap/src/proto/parsers.rs +++ b/imap/src/proto/parsers.rs @@ -5,6 +5,11 @@ use nom::{ Err, IResult, InputIter, Needed, Parser, Slice, }; +/// `sep_list!(t, d)` represents `t *(d t)` and automatically collapses it into `Vec`. +/// +/// 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 { ($t:expr) => { map( @@ -44,8 +49,10 @@ macro_rules! sep_list { }; } +/// Always fails, used as a no-op. pub fn never(i: I) -> IResult { Err(Err::Error(Error::new(i, ErrorKind::Not))) } +/// Skip the part of the input matched by the given parser. pub fn skip(mut f: F) -> impl FnMut(I) -> IResult where I: Clone, @@ -57,6 +64,7 @@ where } } +/// Same as nom satisfy, but operates on `&[u8]` instead of `&str`. pub fn satisfy(f: F) -> impl Fn(I) -> IResult where I: Slice> + InputIter, @@ -71,6 +79,7 @@ where } } +/// Match a single byte exactly. pub fn byte>(b: u8) -> impl Fn(I) -> IResult where I: Slice> + InputIter, diff --git a/imap/src/proto/rfc2177.rs b/imap/src/proto/rfc2177.rs index 0939bb2..c6a85f8 100644 --- a/imap/src/proto/rfc2177.rs +++ b/imap/src/proto/rfc2177.rs @@ -1 +1 @@ -//! Grammar from https://datatracker.ietf.org/doc/html/rfc2177#section-4 +//! Grammar from diff --git a/imap/src/proto/rfc2234.rs b/imap/src/proto/rfc2234.rs index 9f9c26b..b6133b4 100644 --- a/imap/src/proto/rfc2234.rs +++ b/imap/src/proto/rfc2234.rs @@ -1,4 +1,4 @@ -//! Grammar from https://tools.ietf.org/html/rfc2234#section-6.1 +//! Grammar from use nom::{branch::alt, character::streaming::anychar, multi::many0, sequence::pair}; diff --git a/imap/src/proto/rfc3501.rs b/imap/src/proto/rfc3501.rs index 08ac95b..b6d4f76 100644 --- a/imap/src/proto/rfc3501.rs +++ b/imap/src/proto/rfc3501.rs @@ -1,4 +1,4 @@ -//! Grammar from https://datatracker.ietf.org/doc/html/rfc3501#section-9 +//! Grammar from use std::borrow::Cow;