more shifting

This commit is contained in:
Michael Zhang 2021-08-09 18:02:26 -05:00
parent 60e0bb3bbb
commit bbc64fde3b
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
11 changed files with 22 additions and 16 deletions

3
Cargo.lock generated
View file

@ -664,7 +664,6 @@ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
"bitflags", "bitflags",
"bstr",
"bytes", "bytes",
"chrono", "chrono",
"derive_builder", "derive_builder",
@ -685,8 +684,10 @@ name = "panorama-proto-common"
version = "0.0.1" version = "0.0.1"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bstr",
"bytes", "bytes",
"format-bytes", "format-bytes",
"log",
"nom", "nom",
] ]

View file

@ -23,7 +23,6 @@ rfc6154 = [] # list
anyhow = "1.0.42" anyhow = "1.0.42"
async-trait = "0.1.51" async-trait = "0.1.51"
bitflags = "1.2.1" bitflags = "1.2.1"
bstr = "0.2.15"
bytes = "1.0.1" bytes = "1.0.1"
chrono = "0.4.19" chrono = "0.4.19"
derive_builder = "0.10.2" derive_builder = "0.10.2"

View file

@ -2,12 +2,11 @@ use std::io::{self};
use bytes::{BufMut, BytesMut}; use bytes::{BufMut, BytesMut};
use nom::Needed; use nom::Needed;
use panorama_proto_common::Bytes; use panorama_proto_common::{convert_error, Bytes};
use tokio_util::codec::{Decoder, Encoder}; use tokio_util::codec::{Decoder, Encoder};
use crate::proto::{ use crate::proto::{
command::Command, command::Command,
convert_error::convert_error,
response::{Response, Tag}, response::{Response, Tag},
rfc3501::response as parse_response, rfc3501::response as parse_response,
}; };

View file

@ -2,11 +2,6 @@
#![allow(non_snake_case, dead_code)] #![allow(non_snake_case, dead_code)]
// utils
#[macro_use]
mod macros;
pub mod convert_error;
// data types // data types
pub mod command; pub mod command;
pub mod response; pub mod response;

View file

@ -166,4 +166,4 @@ pub enum MailboxListFlag {
Marked, Marked,
Unmarked, Unmarked,
Extension(Atom), Extension(Atom),
} }

View file

@ -26,10 +26,10 @@ fn test_list() {
flags, flags,
delimiter: Some(b'.'), delimiter: Some(b'.'),
mailbox: Mailbox::Name(mailbox), mailbox: Mailbox::Name(mailbox),
}) ) if flags.len() == 3 && }) ) if flags.len() == 3 &&
flags.contains(&MailboxListFlag::Extension(Atom::from(b"HasChildren"))) && flags.contains(&MailboxListFlag::Extension(Atom::from(b"HasChildren"))) &&
flags.contains(&MailboxListFlag::Extension(Atom::from(b"UnMarked"))) && flags.contains(&MailboxListFlag::Extension(Atom::from(b"UnMarked"))) &&
flags.contains(&MailboxListFlag::Extension(Atom::from(b"Trash"))) && flags.contains(&MailboxListFlag::Extension(Atom::from(b"Trash"))) &&
&*mailbox == &b"Trash"[..] &*mailbox == &b"Trash"[..]
)); ));
} }

View file

@ -10,6 +10,8 @@ workspace = ".."
[dependencies] [dependencies]
anyhow = "1.0.42" anyhow = "1.0.42"
bstr = "0.2.15"
bytes = "1.0.1" bytes = "1.0.1"
format-bytes = "0.2.2" format-bytes = "0.2.2"
nom = "6.2.1" log = "0.4.14"
nom = "6.2.1"

View file

@ -1,10 +1,15 @@
#[macro_use] #[macro_use]
extern crate anyhow; extern crate anyhow;
#[macro_use]
extern crate log;
mod bytes; mod bytes;
mod convert_error;
mod formatter; mod formatter;
mod parsers; mod parsers;
mod rule;
pub use crate::bytes::{Bytes, ShitCompare, ShitNeededForParsing}; pub use crate::bytes::{Bytes, ShitCompare, ShitNeededForParsing};
pub use crate::convert_error::convert_error;
pub use crate::formatter::quote_string; pub use crate::formatter::quote_string;
pub use crate::parsers::{byte, never, parse_u32, satisfy, skip, tagi, take, take_while1, VResult}; pub use crate::parsers::{byte, never, parse_u32, satisfy, skip, tagi, take, take_while1, VResult};

View file

@ -1,3 +1,7 @@
use crate::{Bytes, VResult};
/// Defines a new parser rule that operates on [`Bytes`] and produces a [`VResult`].
#[macro_export]
macro_rules! rule { macro_rules! rule {
($vis:vis $name:ident : $ret:ty => $expr:expr) => { ($vis:vis $name:ident : $ret:ty => $expr:expr) => {
$vis fn $name ( $vis fn $name (

View file

@ -1,4 +1,5 @@
//! SMTP Specification //! SMTP Specification
//! --- //! ---
//! //!
//! Grammar from <https://datatracker.ietf.org/doc/html/rfc5321> //! Grammar from <https://datatracker.ietf.org/doc/html/rfc5321>