Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass IDLE responses to caller. #186

Merged
merged 23 commits into from
Apr 20, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
529401a
Implement a method to pass unilateral responses while IDLE.
mordak Mar 14, 2021
2874bfd
Add IDLE example.
mordak Mar 28, 2021
c9b7c0a
Update src/extensions/idle.rs
mordak Apr 5, 2021
5e3f087
Merge remote-tracking branch 'origin/master' into idle-responses
mordak Apr 5, 2021
bbff7d4
Remove deprecated wait_timeout()
mordak Apr 5, 2021
bb38142
Change callback_stop to stop_on_any.
mordak Apr 5, 2021
e8a7c91
Comment example where we turn on debugging.
mordak Apr 5, 2021
b8bd1e4
Reorder UnsolicitedResponse alphabetically so it is easier to follow.
mordak Apr 5, 2021
e1db863
Add helper function to transform a vec of flag strings into a vec of …
mordak Apr 5, 2021
064c2e0
Use drain() instead of reallocating.
mordak Apr 5, 2021
ff39ebf
Merge branch 'idle-responses' of github.com:mordak/rust-imap into idl…
mordak Apr 5, 2021
9126d3c
Improve documentation around unhandled responses.
mordak Apr 7, 2021
11adcfc
Tweak to how we handle incomplete parse.
mordak Apr 7, 2021
5942553
Use iterators for Flag::from_strs()
mordak Apr 7, 2021
7eb2cfd
Use bool instead of CallbackAction.
mordak Apr 7, 2021
efa02f0
Remove wrapper around ResponseCode.
mordak Apr 8, 2021
f2d7919
Do not wrap AttributeValue.
mordak Apr 8, 2021
584c954
Reorder variants alphabetically in try_from.
mordak Apr 8, 2021
692dcdd
Move buffer management into parse match arms.
mordak Apr 8, 2021
4232c77
wait to wait_while
mordak Apr 8, 2021
08de336
Move debug assertion.
mordak Apr 9, 2021
1cabb3b
Promote Unexpected error from ParseError to Error.
mordak Apr 20, 2021
48db461
Merge remote-tracking branch 'origin/master' into idle-responses
mordak Apr 20, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ pub fn parse_fetches(
use imap_proto::AttributeValue;
match attr {
AttributeValue::Flags(flags) => {
fetch.flags.extend(Flag::from_vec(flags));
fetch.flags.extend(Flag::from_strs(flags));
}
AttributeValue::Uid(uid) => fetch.uid = Some(*uid),
AttributeValue::Rfc822Size(sz) => fetch.size = Some(*sz),
Expand Down Expand Up @@ -269,7 +269,7 @@ pub fn parse_mailbox(
mailbox.unseen = Some(n);
}
Some(ResponseCode::PermanentFlags(flags)) => {
mailbox.permanent_flags.extend(Flag::from_vec(&flags));
mailbox.permanent_flags.extend(Flag::from_strs(flags));
}
_ => {}
}
Expand All @@ -293,7 +293,7 @@ pub fn parse_mailbox(
mailbox.recent = r;
}
MailboxDatum::Flags(flags) => {
mailbox.flags.extend(Flag::from_vec(&flags));
mailbox.flags.extend(Flag::from_strs(flags));
}
_ => {}
}
Expand Down
8 changes: 5 additions & 3 deletions src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,11 @@ impl Flag<'static> {
}
}

/// Helper function to transform a [`Vec`] of flag strings into a [`Vec`] of [`Flag`].
pub fn from_vec<S: ToString>(v: &[S]) -> Vec<Self> {
v.iter().map(|s| Self::from(s.to_string())).collect()
/// Helper function to transform Strings into owned Flags
pub fn from_strs<S: ToString>(
jonhoo marked this conversation as resolved.
Show resolved Hide resolved
v: impl IntoIterator<Item = S>,
) -> impl Iterator<Item = Flag<'static>> {
v.into_iter().map(|s| Flag::from(s.to_string()))
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/types/unsolicited_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ impl<'a> TryFrom<Response<'a>> for UnsolicitedResponse {
}
Response::MailboxData(MailboxDatum::Recent(n)) => Ok(UnsolicitedResponse::Recent(n)),
Response::MailboxData(MailboxDatum::Flags(flags)) => {
Ok(UnsolicitedResponse::Flags(Flag::from_vec(&flags)))
Ok(UnsolicitedResponse::Flags(Flag::from_strs(flags).collect()))
}
Response::MailboxData(MailboxDatum::Exists(n)) => Ok(UnsolicitedResponse::Exists(n)),
Response::MailboxData(MailboxDatum::MetadataUnsolicited { mailbox, values }) => {
Expand Down Expand Up @@ -288,7 +288,7 @@ impl<'a> TryFrom<&ImapProtoAttributeValue<'a>> for AttributeValue {
fn try_from(val: &ImapProtoAttributeValue<'a>) -> Result<Self, Self::Error> {
match val {
ImapProtoAttributeValue::Flags(flags) => {
Ok(AttributeValue::Flags(Flag::from_vec(&flags)))
Ok(AttributeValue::Flags(Flag::from_strs(flags).collect()))
}
ImapProtoAttributeValue::ModSeq(seq) => Ok(AttributeValue::ModSeq(*seq)),
ImapProtoAttributeValue::Uid(uid) => Ok(AttributeValue::Uid(*uid)),
Expand Down