Rename handle_unilateral to try_handle_unilateral.
More accurately conveys that the function might not actually handle it.
This commit is contained in:
parent
bd0a04567b
commit
ec835d67e4
2 changed files with 11 additions and 10 deletions
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
use crate::client::*;
|
||||
use crate::error::{Error, ParseError, Result};
|
||||
use crate::parse::handle_unilateral;
|
||||
use crate::parse::try_handle_unilateral;
|
||||
use crate::types::*;
|
||||
use imap_proto::types::{MailboxDatum, Metadata, Response, ResponseCode};
|
||||
use std::io::{Read, Write};
|
||||
|
|
@ -97,7 +97,7 @@ fn parse_metadata<'a>(
|
|||
res.append(&mut values);
|
||||
}
|
||||
_ => {
|
||||
if let Some(unhandled) = handle_unilateral(resp, unsolicited) {
|
||||
if let Some(unhandled) = try_handle_unilateral(resp, unsolicited) {
|
||||
break Err(unhandled.into());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
17
src/parse.rs
17
src/parse.rs
|
|
@ -50,7 +50,7 @@ where
|
|||
|
||||
match map(resp)? {
|
||||
MapOrNot::Map(t) => things.push(t),
|
||||
MapOrNot::Not(resp) => match handle_unilateral(resp, unsolicited) {
|
||||
MapOrNot::Not(resp) => match try_handle_unilateral(resp, unsolicited) {
|
||||
Some(Response::Fetch(..)) => continue,
|
||||
Some(resp) => break Err(resp.into()),
|
||||
None => {}
|
||||
|
|
@ -150,7 +150,7 @@ pub fn parse_expunge(
|
|||
}
|
||||
Ok((rest, data)) => {
|
||||
lines = rest;
|
||||
if let Some(resp) = handle_unilateral(data, unsolicited) {
|
||||
if let Some(resp) = try_handle_unilateral(data, unsolicited) {
|
||||
return Err(resp.into());
|
||||
}
|
||||
}
|
||||
|
|
@ -185,7 +185,7 @@ pub fn parse_capabilities(
|
|||
}
|
||||
Ok((rest, data)) => {
|
||||
lines = rest;
|
||||
if let Some(resp) = handle_unilateral(data, unsolicited) {
|
||||
if let Some(resp) = try_handle_unilateral(data, unsolicited) {
|
||||
break Err(resp.into());
|
||||
}
|
||||
}
|
||||
|
|
@ -217,7 +217,7 @@ pub fn parse_noop(
|
|||
match imap_proto::parser::parse_response(lines) {
|
||||
Ok((rest, data)) => {
|
||||
lines = rest;
|
||||
if let Some(resp) = handle_unilateral(data, unsolicited) {
|
||||
if let Some(resp) = try_handle_unilateral(data, unsolicited) {
|
||||
break Err(resp.into());
|
||||
}
|
||||
}
|
||||
|
|
@ -339,7 +339,7 @@ pub fn parse_ids(
|
|||
}
|
||||
Ok((rest, data)) => {
|
||||
lines = rest;
|
||||
if let Some(resp) = handle_unilateral(data, unsolicited) {
|
||||
if let Some(resp) = try_handle_unilateral(data, unsolicited) {
|
||||
break Err(resp.into());
|
||||
}
|
||||
}
|
||||
|
|
@ -350,9 +350,10 @@ pub fn parse_ids(
|
|||
}
|
||||
}
|
||||
|
||||
// check if this is simply a unilateral server response
|
||||
// (see Section 7 of RFC 3501):
|
||||
pub(crate) fn handle_unilateral<'a>(
|
||||
// Check if this is simply a unilateral server response (see Section 7 of RFC 3501).
|
||||
//
|
||||
// Returns `None` if the response was handled, `Some(res)` if not.
|
||||
pub(crate) fn try_handle_unilateral<'a>(
|
||||
res: Response<'a>,
|
||||
unsolicited: &mut mpsc::Sender<UnsolicitedResponse>,
|
||||
) -> Option<Response<'a>> {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue