Reformat code
This commit is contained in:
parent
b83c4fd065
commit
c63bf04601
|
@ -1,6 +1,7 @@
|
|||
use smtp_codec::parse::command::command;
|
||||
use std::io::Write;
|
||||
|
||||
use smtp_codec::parse::command::command;
|
||||
|
||||
fn main() -> std::io::Result<()> {
|
||||
let mut args = std::env::args();
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
//! 4.1.3. Address Literals (RFC 5321)
|
||||
|
||||
use crate::parse::Ldh_str;
|
||||
use abnf_core::streaming::is_DIGIT;
|
||||
use nom::{
|
||||
branch::alt,
|
||||
|
@ -12,6 +11,8 @@ use nom::{
|
|||
IResult,
|
||||
};
|
||||
|
||||
use crate::parse::Ldh_str;
|
||||
|
||||
/// address-literal = "[" (
|
||||
/// IPv4-address-literal /
|
||||
/// IPv6-address-literal /
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
use crate::{
|
||||
parse::{address::address_literal, base64, Atom, Domain, Quoted_string, String},
|
||||
types::{Command, DomainOrAddress, Parameter},
|
||||
};
|
||||
use abnf_core::streaming::{is_ALPHA, is_DIGIT, CRLF, SP};
|
||||
use nom::{
|
||||
branch::alt,
|
||||
|
@ -12,6 +8,11 @@ use nom::{
|
|||
IResult,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
parse::{address::address_literal, base64, Atom, Domain, Quoted_string, String},
|
||||
types::{Command, DomainOrAddress, Parameter},
|
||||
};
|
||||
|
||||
pub fn command(input: &[u8]) -> IResult<&[u8], Command> {
|
||||
alt((
|
||||
helo, ehlo, mail, rcpt, data, rset, vrfy, expn, help, noop, quit,
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
/// 3.2.1. Quoted characters
|
||||
pub mod quoted_characters {
|
||||
use super::obsolete::obs_qp;
|
||||
use abnf_core::streaming::{is_VCHAR, WSP};
|
||||
use nom::{
|
||||
branch::alt,
|
||||
|
@ -14,6 +13,8 @@ pub mod quoted_characters {
|
|||
IResult,
|
||||
};
|
||||
|
||||
use super::obsolete::obs_qp;
|
||||
|
||||
/// quoted-pair = ("\" (VCHAR / WSP)) / obs-qp
|
||||
pub fn quoted_pair(input: &[u8]) -> IResult<&[u8], &[u8]> {
|
||||
let parser = alt((
|
||||
|
@ -57,7 +58,6 @@ pub mod folding_ws_and_comment {
|
|||
|
||||
/// 3.2.3. Atom
|
||||
pub mod atom {
|
||||
use super::folding_ws_and_comment::CFWS;
|
||||
use abnf_core::streaming::{is_ALPHA, is_DIGIT};
|
||||
use nom::{
|
||||
bytes::streaming::{tag, take_while1},
|
||||
|
@ -67,6 +67,8 @@ pub mod atom {
|
|||
IResult,
|
||||
};
|
||||
|
||||
use super::folding_ws_and_comment::CFWS;
|
||||
|
||||
/// Printable US-ASCII characters not including specials.
|
||||
/// Used for atoms.
|
||||
///
|
||||
|
@ -131,11 +133,6 @@ pub mod atom {
|
|||
|
||||
/// 3.2.4. Quoted Strings
|
||||
pub mod quoted_strings {
|
||||
use super::{
|
||||
folding_ws_and_comment::{CFWS, FWS},
|
||||
obsolete::is_obs_qtext,
|
||||
quoted_characters::quoted_pair,
|
||||
};
|
||||
use abnf_core::streaming::DQUOTE;
|
||||
use nom::{
|
||||
branch::alt,
|
||||
|
@ -146,6 +143,12 @@ pub mod quoted_strings {
|
|||
IResult,
|
||||
};
|
||||
|
||||
use super::{
|
||||
folding_ws_and_comment::{CFWS, FWS},
|
||||
obsolete::is_obs_qtext,
|
||||
quoted_characters::quoted_pair,
|
||||
};
|
||||
|
||||
/// Printable US-ASCII characters not including "\" or the quote character.
|
||||
///
|
||||
/// qtext = %d33 / %d35-91 / %d93-126 / obs-qtext
|
||||
|
@ -185,9 +188,10 @@ pub mod quoted_strings {
|
|||
|
||||
/// 3.2.5. Miscellaneous Tokens
|
||||
pub mod miscellaneous {
|
||||
use super::{atom::atom, quoted_strings::quoted_string};
|
||||
use nom::{branch::alt, IResult};
|
||||
|
||||
use super::{atom::atom, quoted_strings::quoted_string};
|
||||
|
||||
/// word = atom / quoted-string
|
||||
pub fn word(input: &[u8]) -> IResult<&[u8], &[u8]> {
|
||||
alt((atom, quoted_string))(input)
|
||||
|
@ -202,7 +206,6 @@ pub mod miscellaneous {
|
|||
|
||||
/// 3.3. Date and Time Specification
|
||||
pub mod datetime {
|
||||
use super::folding_ws_and_comment::{CFWS, FWS};
|
||||
use abnf_core::streaming::is_DIGIT;
|
||||
use nom::{
|
||||
branch::alt,
|
||||
|
@ -212,6 +215,8 @@ pub mod datetime {
|
|||
IResult,
|
||||
};
|
||||
|
||||
use super::folding_ws_and_comment::{CFWS, FWS};
|
||||
|
||||
// date-time = [ day-of-week "," ] date time [CFWS]
|
||||
pub fn date_time(input: &[u8]) -> IResult<&[u8], &[u8]> {
|
||||
let parser = tuple((opt(tuple((day_of_week, tag(b",")))), date, time, opt(CFWS)));
|
||||
|
@ -365,12 +370,6 @@ pub mod datetime {
|
|||
|
||||
/// 3.4.1. Addr-Spec Specification
|
||||
pub mod addr_spec {
|
||||
use super::{
|
||||
atom::dot_atom,
|
||||
folding_ws_and_comment::{CFWS, FWS},
|
||||
obsolete::{obs_domain, obs_dtext, obs_local_part},
|
||||
quoted_strings::quoted_string,
|
||||
};
|
||||
use nom::{
|
||||
branch::alt,
|
||||
bytes::streaming::{tag, take_while_m_n},
|
||||
|
@ -380,6 +379,13 @@ pub mod addr_spec {
|
|||
IResult,
|
||||
};
|
||||
|
||||
use super::{
|
||||
atom::dot_atom,
|
||||
folding_ws_and_comment::{CFWS, FWS},
|
||||
obsolete::{obs_domain, obs_dtext, obs_local_part},
|
||||
quoted_strings::quoted_string,
|
||||
};
|
||||
|
||||
// addr-spec = local-part "@" domain
|
||||
|
||||
/// local-part = dot-atom / quoted-string / obs-local-part
|
||||
|
@ -442,12 +448,6 @@ pub mod addr_spec {
|
|||
|
||||
/// 3.6.4. Identification Fields
|
||||
pub mod identification {
|
||||
use super::{
|
||||
addr_spec::dtext,
|
||||
atom::dot_atom_text,
|
||||
folding_ws_and_comment::CFWS,
|
||||
obsolete::{obs_id_left, obs_id_right},
|
||||
};
|
||||
use nom::{
|
||||
branch::alt,
|
||||
bytes::streaming::tag,
|
||||
|
@ -457,6 +457,13 @@ pub mod identification {
|
|||
IResult,
|
||||
};
|
||||
|
||||
use super::{
|
||||
addr_spec::dtext,
|
||||
atom::dot_atom_text,
|
||||
folding_ws_and_comment::CFWS,
|
||||
obsolete::{obs_id_left, obs_id_right},
|
||||
};
|
||||
|
||||
// message-id = "Message-ID:" msg-id CRLF
|
||||
// ...
|
||||
|
||||
|
@ -513,12 +520,6 @@ pub mod identification {
|
|||
|
||||
/// 4.1. Miscellaneous Obsolete Tokens
|
||||
pub mod obsolete {
|
||||
use super::{
|
||||
addr_spec::{domain, local_part},
|
||||
atom::atom,
|
||||
miscellaneous::word,
|
||||
quoted_characters::quoted_pair,
|
||||
};
|
||||
use abnf_core::streaming::{CR, LF};
|
||||
use nom::{
|
||||
branch::alt,
|
||||
|
@ -529,6 +530,13 @@ pub mod obsolete {
|
|||
IResult,
|
||||
};
|
||||
|
||||
use super::{
|
||||
addr_spec::{domain, local_part},
|
||||
atom::atom,
|
||||
miscellaneous::word,
|
||||
quoted_characters::quoted_pair,
|
||||
};
|
||||
|
||||
/// US-ASCII control characters that do not include the carriage
|
||||
/// return, line feed, and white space characters
|
||||
///
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#![allow(non_snake_case)]
|
||||
|
||||
use crate::{parse::imf::atom::is_atext, types::AtomOrQuoted, utils::unescape_quoted};
|
||||
use std::{borrow::Cow, str::from_utf8};
|
||||
|
||||
use abnf_core::streaming::{is_ALPHA, is_DIGIT, DQUOTE};
|
||||
use nom::{
|
||||
branch::alt,
|
||||
|
@ -11,7 +12,8 @@ use nom::{
|
|||
sequence::{delimited, tuple},
|
||||
IResult,
|
||||
};
|
||||
use std::{borrow::Cow, str::from_utf8};
|
||||
|
||||
use crate::{parse::imf::atom::is_atext, types::AtomOrQuoted, utils::unescape_quoted};
|
||||
|
||||
pub mod address;
|
||||
pub mod command;
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
use crate::{
|
||||
parse::{address::address_literal, number, Domain},
|
||||
types::{AuthMechanism, Capability, Response},
|
||||
};
|
||||
use abnf_core::streaming::{is_ALPHA, is_DIGIT, CRLF, SP};
|
||||
use nom::{
|
||||
branch::alt,
|
||||
|
@ -12,6 +8,11 @@ use nom::{
|
|||
IResult,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
parse::{address::address_literal, number, Domain},
|
||||
types::{AuthMechanism, Capability, Response},
|
||||
};
|
||||
|
||||
/// Greeting = ( "220 " (Domain / address-literal) [ SP textstring ] CRLF ) /
|
||||
/// ( "220-" (Domain / address-literal) [ SP textstring ] CRLF
|
||||
/// *( "220-" [ textstring ] CRLF )
|
||||
|
|
|
@ -1,13 +1,3 @@
|
|||
use crate::parse::{
|
||||
address::address_literal,
|
||||
command::{Mailbox, Path, Reverse_path},
|
||||
imf::{
|
||||
datetime::date_time,
|
||||
folding_ws_and_comment::{CFWS, FWS},
|
||||
identification::msg_id,
|
||||
},
|
||||
Atom, Domain, String,
|
||||
};
|
||||
/// 4.4. Trace Information (RFC 5321)
|
||||
use abnf_core::streaming::CRLF;
|
||||
use nom::{
|
||||
|
@ -19,6 +9,17 @@ use nom::{
|
|||
IResult,
|
||||
};
|
||||
|
||||
use crate::parse::{
|
||||
address::address_literal,
|
||||
command::{Mailbox, Path, Reverse_path},
|
||||
imf::{
|
||||
datetime::date_time,
|
||||
folding_ws_and_comment::{CFWS, FWS},
|
||||
identification::msg_id,
|
||||
},
|
||||
Atom, Domain, String,
|
||||
};
|
||||
|
||||
/// Return-path-line = "Return-Path:" FWS Reverse-path <CRLF>
|
||||
pub fn Return_path_line(input: &[u8]) -> IResult<&[u8], &[u8]> {
|
||||
let parser = tuple((tag_no_case(b"Return-Path:"), FWS, Reverse_path, CRLF));
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
use crate::utils::escape_quoted;
|
||||
use std::io::Write;
|
||||
|
||||
#[cfg(feature = "serdex")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::io::Write;
|
||||
|
||||
use crate::utils::escape_quoted;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum Command {
|
||||
|
|
Loading…
Reference in New Issue