mirror of
https://github.com/instant-labs/instant-smtp.git
synced 2025-02-15 06:22:20 +00:00
Thanks Clippy!
This commit is contained in:
parent
cc8551e357
commit
f5f04ea5e3
@ -54,10 +54,7 @@ pub fn Standardized_tag(input: &[u8]) -> IResult<&[u8], &[u8]> {
|
|||||||
///
|
///
|
||||||
/// dcontent = %d33-90 / %d94-126
|
/// dcontent = %d33-90 / %d94-126
|
||||||
pub fn is_dcontent(byte: u8) -> bool {
|
pub fn is_dcontent(byte: u8) -> bool {
|
||||||
match byte {
|
matches!(byte, 33..=90 | 94..=126)
|
||||||
33..=90 | 94..=126 => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Representing a decimal integer value in the range 0 through 255
|
/// Representing a decimal integer value in the range 0 through 255
|
||||||
|
@ -354,10 +354,7 @@ pub fn esmtp_keyword(input: &[u8]) -> IResult<&[u8], &[u8]> {
|
|||||||
/// esmtp-value = 1*(%d33-60 / %d62-126)
|
/// esmtp-value = 1*(%d33-60 / %d62-126)
|
||||||
pub fn esmtp_value(input: &[u8]) -> IResult<&[u8], &[u8]> {
|
pub fn esmtp_value(input: &[u8]) -> IResult<&[u8], &[u8]> {
|
||||||
fn is_value_character(byte: u8) -> bool {
|
fn is_value_character(byte: u8) -> bool {
|
||||||
match byte {
|
matches!(byte, 33..=60 | 62..=126)
|
||||||
33..=60 | 62..=126 => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
take_while1(is_value_character)(input)
|
take_while1(is_value_character)(input)
|
||||||
@ -494,10 +491,7 @@ pub fn QcontentSMTP(input: &[u8]) -> IResult<&[u8], &[u8]> {
|
|||||||
/// quoted-pairSMTP = %d92 %d32-126
|
/// quoted-pairSMTP = %d92 %d32-126
|
||||||
pub fn quoted_pairSMTP(input: &[u8]) -> IResult<&[u8], &[u8]> {
|
pub fn quoted_pairSMTP(input: &[u8]) -> IResult<&[u8], &[u8]> {
|
||||||
fn is_ascii_bs_or_sp(byte: u8) -> bool {
|
fn is_ascii_bs_or_sp(byte: u8) -> bool {
|
||||||
match byte {
|
matches!(byte, 32..=126)
|
||||||
32..=126 => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let parser = tuple((tag("\\"), take_while_m_n(1, 1, is_ascii_bs_or_sp)));
|
let parser = tuple((tag("\\"), take_while_m_n(1, 1, is_ascii_bs_or_sp)));
|
||||||
@ -512,10 +506,7 @@ pub fn quoted_pairSMTP(input: &[u8]) -> IResult<&[u8], &[u8]> {
|
|||||||
///
|
///
|
||||||
/// qtextSMTP = %d32-33 / %d35-91 / %d93-126
|
/// qtextSMTP = %d32-33 / %d35-91 / %d93-126
|
||||||
pub fn is_qtextSMTP(byte: u8) -> bool {
|
pub fn is_qtextSMTP(byte: u8) -> bool {
|
||||||
match byte {
|
matches!(byte, 32..=33 | 35..=91 | 93..=126)
|
||||||
32..=33 | 35..=91 | 93..=126 => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// String = Atom / Quoted-string
|
/// String = Atom / Quoted-string
|
||||||
|
@ -421,17 +421,11 @@ pub mod addr_spec {
|
|||||||
/// dtext = %d33-90 / %d94-126 / obs-dtext
|
/// dtext = %d33-90 / %d94-126 / obs-dtext
|
||||||
pub fn dtext(input: &[u8]) -> IResult<&[u8], &[u8]> {
|
pub fn dtext(input: &[u8]) -> IResult<&[u8], &[u8]> {
|
||||||
fn is_a(byte: u8) -> bool {
|
fn is_a(byte: u8) -> bool {
|
||||||
match byte {
|
matches!(byte, 33..=90)
|
||||||
33..=90 => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_b(byte: u8) -> bool {
|
fn is_b(byte: u8) -> bool {
|
||||||
match byte {
|
matches!(byte, 94..=126)
|
||||||
94..=126 => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let parser = alt((
|
let parser = alt((
|
||||||
@ -540,10 +534,7 @@ pub mod obsolete {
|
|||||||
///
|
///
|
||||||
/// obs-NO-WS-CTL = %d1-8 / %d11 / %d12 / %d14-31 / %d127
|
/// obs-NO-WS-CTL = %d1-8 / %d11 / %d12 / %d14-31 / %d127
|
||||||
pub fn is_obs_NO_WS_CTL(byte: u8) -> bool {
|
pub fn is_obs_NO_WS_CTL(byte: u8) -> bool {
|
||||||
match byte {
|
matches!(byte, 1..=8 | 11 | 12 | 14..=31 | 127)
|
||||||
1..=8 | 11 | 12 | 14..=31 | 127 => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// obs-qtext = obs-NO-WS-CTL
|
/// obs-qtext = obs-NO-WS-CTL
|
||||||
|
@ -31,7 +31,7 @@ pub fn Greeting(input: &[u8]) -> IResult<&[u8], GreetingType> {
|
|||||||
domain: domain.to_owned(),
|
domain: domain.to_owned(),
|
||||||
text: maybe_text
|
text: maybe_text
|
||||||
.map(|str| str.to_string())
|
.map(|str| str.to_string())
|
||||||
.unwrap_or("".to_string()),
|
.unwrap_or_else(|| "".to_string()),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
map(
|
map(
|
||||||
@ -50,18 +50,18 @@ pub fn Greeting(input: &[u8]) -> IResult<&[u8], GreetingType> {
|
|||||||
text: {
|
text: {
|
||||||
let mut res = maybe_text
|
let mut res = maybe_text
|
||||||
.map(|str| format!("{}\n", str))
|
.map(|str| format!("{}\n", str))
|
||||||
.unwrap_or("\n".to_string());
|
.unwrap_or_else(|| "\n".to_string());
|
||||||
|
|
||||||
for text in more_text {
|
for text in more_text {
|
||||||
let text = text
|
let text = text
|
||||||
.map(|str| format!("{}\n", str))
|
.map(|str| format!("{}\n", str))
|
||||||
.unwrap_or("\n".to_string());
|
.unwrap_or_else(|| "\n".to_string());
|
||||||
res.push_str(&text);
|
res.push_str(&text);
|
||||||
}
|
}
|
||||||
|
|
||||||
let text = moar_text
|
let text = moar_text
|
||||||
.map(|str| format!("{}", str))
|
.map(|str| str.to_string())
|
||||||
.unwrap_or("".to_string());
|
.unwrap_or_else(|| "".to_string());
|
||||||
res.push_str(&text);
|
res.push_str(&text);
|
||||||
|
|
||||||
res
|
res
|
||||||
@ -80,10 +80,7 @@ pub fn Greeting(input: &[u8]) -> IResult<&[u8], GreetingType> {
|
|||||||
/// textstring = 1*(%d09 / %d32-126)
|
/// textstring = 1*(%d09 / %d32-126)
|
||||||
pub fn textstring(input: &[u8]) -> IResult<&[u8], &str> {
|
pub fn textstring(input: &[u8]) -> IResult<&[u8], &str> {
|
||||||
fn is_value(byte: u8) -> bool {
|
fn is_value(byte: u8) -> bool {
|
||||||
match byte {
|
matches!(byte, 9 | 32..=126)
|
||||||
9 | 32..=126 => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let (remaining, parsed) = map_res(take_while1(is_value), std::str::from_utf8)(input)?;
|
let (remaining, parsed) = map_res(take_while1(is_value), std::str::from_utf8)(input)?;
|
||||||
|
@ -73,10 +73,7 @@ pub fn ehlo_ok_rsp(input: &[u8]) -> IResult<&[u8], EhloOkResp> {
|
|||||||
/// ehlo-greet = 1*(%d0-9 / %d11-12 / %d14-127)
|
/// ehlo-greet = 1*(%d0-9 / %d11-12 / %d14-127)
|
||||||
pub fn ehlo_greet(input: &[u8]) -> IResult<&[u8], &str> {
|
pub fn ehlo_greet(input: &[u8]) -> IResult<&[u8], &str> {
|
||||||
fn is_valid_character(byte: u8) -> bool {
|
fn is_valid_character(byte: u8) -> bool {
|
||||||
match byte {
|
matches!(byte, 0..=9 | 11..=12 | 14..=127)
|
||||||
0..=9 | 11..=12 | 14..=127 => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
map_res(take_while1(is_valid_character), std::str::from_utf8)(input)
|
map_res(take_while1(is_valid_character), std::str::from_utf8)(input)
|
||||||
@ -96,7 +93,7 @@ pub fn ehlo_line(input: &[u8]) -> IResult<&[u8], (&str, Vec<&str>)> {
|
|||||||
|
|
||||||
let (remaining, (ehlo_keyword, ehlo_params)) = parser(input)?;
|
let (remaining, (ehlo_keyword, ehlo_params)) = parser(input)?;
|
||||||
|
|
||||||
Ok((remaining, (ehlo_keyword, ehlo_params.unwrap_or(vec![]))))
|
Ok((remaining, (ehlo_keyword, ehlo_params.unwrap_or_default())))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Additional syntax of ehlo-params depends on ehlo-keyword
|
/// Additional syntax of ehlo-params depends on ehlo-keyword
|
||||||
@ -119,10 +116,7 @@ pub fn ehlo_keyword(input: &[u8]) -> IResult<&[u8], &[u8]> {
|
|||||||
/// ehlo-param = 1*(%d33-126)
|
/// ehlo-param = 1*(%d33-126)
|
||||||
pub fn ehlo_param(input: &[u8]) -> IResult<&[u8], &str> {
|
pub fn ehlo_param(input: &[u8]) -> IResult<&[u8], &str> {
|
||||||
fn is_valid_character(byte: u8) -> bool {
|
fn is_valid_character(byte: u8) -> bool {
|
||||||
match byte {
|
matches!(byte, 33..=126)
|
||||||
33..=126 => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
map_res(take_while1(is_valid_character), std::str::from_utf8)(input)
|
map_res(take_while1(is_valid_character), std::str::from_utf8)(input)
|
||||||
|
Loading…
Reference in New Issue
Block a user