Skip to main content

ImapClientStd

Struct ImapClientStd 

Source
pub struct ImapClientStd {
    pub stream: Box<dyn ImapStream>,
    pub fragmentizer: Fragmentizer,
    pub auto_id: Option<Vec<(IString<'static>, NString<'static>)>>,
}
Available on crate feature client only.
Expand description

auto_id is consumed by every auth_*/login: None skips, Some(empty) sends ID NIL, Some(params) sends ID (k v ...). Required by a few providers (mail.qq.com, fastmail).

Fields§

§stream: Box<dyn ImapStream>§fragmentizer: Fragmentizer§auto_id: Option<Vec<(IString<'static>, NString<'static>)>>

Implementations§

Source§

impl ImapClientStd

Source

pub fn new<S: Read + Write + Send + 'static>(stream: S) -> Self

Caller is responsible for opening the connection (TCP, TLS, STARTTLS).

Source

pub fn set_stream<S: Read + Write + Send + 'static>(&mut self, stream: S)

Useful after a STARTTLS upgrade or on reconnection.

Source

pub fn run<C, T, E>(&mut self, coroutine: C) -> Result<T, ImapClientStdError>
where C: ImapCoroutine<Yield = ImapYield, Return = Result<T, E>>, ImapClientStdError: From<E>,

Drives a standard-shape coroutine to completion. Richer yields (IDLE events, watch deltas) need their own per-method loops.

Source

pub fn greeting( &mut self, ) -> Result<Vec<Capability<'static>>, ImapClientStdError>

Consumes the greeting and returns the advertised capabilities (forcing a CAPABILITY round-trip if the greeting carried none).

Source

pub fn login( &mut self, user: impl AsRef<str>, password: impl AsRef<str>, opts: ImapLoginOptions, ) -> Result<Vec<Capability<'static>>, ImapClientStdError>

LOGIN. Channel must be TLS-protected. Consumes auto_id.

Source

pub fn starttls(&mut self) -> Result<Vec<u8>, ImapClientStdError>

STARTTLS. Caller still has to upgrade the socket and refresh capabilities. Returns any bytes pre-read past the tagged response (a non-empty return is a STARTTLS-injection signal: refuse the upgrade).

Source

pub fn auth_anonymous( &mut self, message: Option<impl AsRef<str>>, opts: ImapAuthAnonymousOptions, ) -> Result<Vec<Capability<'static>>, ImapClientStdError>

SASL AUTHENTICATE ANONYMOUS. Consumes auto_id.

Source

pub fn auth_login( &mut self, user: impl AsRef<str>, password: impl AsRef<str>, opts: ImapAuthLoginOptions, ) -> Result<Vec<Capability<'static>>, ImapClientStdError>

SASL AUTHENTICATE LOGIN (legacy). Prefer auth_plain or auth_scram_sha256 when supported. Consumes auto_id.

Source

pub fn auth_plain( &mut self, authzid: Option<impl AsRef<str>>, authcid: impl AsRef<str>, password: impl AsRef<str>, opts: ImapAuthPlainOptions, ) -> Result<Vec<Capability<'static>>, ImapClientStdError>

SASL AUTHENTICATE PLAIN. Consumes auto_id.

Source

pub fn auth_oauthbearer( &mut self, user: impl AsRef<str>, host: impl AsRef<str>, port: u16, token: impl AsRef<str>, opts: ImapAuthOauthbearerOptions, ) -> Result<Vec<Capability<'static>>, ImapClientStdError>

SASL AUTHENTICATE OAUTHBEARER. Channel must be TLS-protected. Consumes auto_id.

Source

pub fn auth_xoauth2( &mut self, user: impl AsRef<str>, token: impl AsRef<str>, opts: ImapAuthXoauth2Options, ) -> Result<Vec<Capability<'static>>, ImapClientStdError>

SASL AUTHENTICATE XOAUTH2 (Google’s pre-standard mechanism). Prefer auth_oauthbearer when supported. Consumes auto_id.

Source

pub fn auth_scram_sha256( &mut self, user: impl AsRef<str>, password: impl AsRef<str>, opts: ImapAuthScramSha256Options, ) -> Result<Vec<Capability<'static>>, ImapClientStdError>

Available on crate feature scram only.

SASL AUTHENTICATE SCRAM-SHA-256. Consumes auto_id.

Source

pub fn logout(&mut self) -> Result<(), ImapClientStdError>

Source

pub fn capability( &mut self, ) -> Result<Vec<Capability<'static>>, ImapClientStdError>

Source

pub fn noop(&mut self) -> Result<(), ImapClientStdError>

Source

pub fn id( &mut self, parameters: Option<Vec<(IString<'static>, NString<'static>)>>, ) -> Result<Option<Vec<(IString<'static>, NString<'static>)>>, ImapClientStdError>

ID. None sends ID NIL.

Source

pub fn enable( &mut self, capabilities: Vec1<CapabilityEnable<'static>>, ) -> Result<Option<Vec<CapabilityEnable<'static>>>, ImapClientStdError>

Source

pub fn list( &mut self, reference: Mailbox<'static>, pattern: ListMailbox<'static>, ) -> Result<ImapMailboxListing, ImapClientStdError>

Source

pub fn lsub( &mut self, reference: Mailbox<'static>, pattern: ListMailbox<'static>, ) -> Result<ImapMailboxListing, ImapClientStdError>

Source

pub fn status( &mut self, mailbox: Mailbox<'static>, item_names: impl Into<Cow<'static, [StatusDataItemName]>>, ) -> Result<Vec<StatusDataItem>, ImapClientStdError>

Source

pub fn create( &mut self, mailbox: Mailbox<'static>, ) -> Result<(), ImapClientStdError>

Source

pub fn delete( &mut self, mailbox: Mailbox<'static>, ) -> Result<(), ImapClientStdError>

Source

pub fn rename( &mut self, from: Mailbox<'static>, to: Mailbox<'static>, ) -> Result<(), ImapClientStdError>

Source

pub fn subscribe( &mut self, mailbox: Mailbox<'static>, ) -> Result<(), ImapClientStdError>

Source

pub fn unsubscribe( &mut self, mailbox: Mailbox<'static>, ) -> Result<(), ImapClientStdError>

Source

pub fn select( &mut self, mailbox: Mailbox<'static>, ) -> Result<SelectData, ImapClientStdError>

Source

pub fn examine( &mut self, mailbox: Mailbox<'static>, ) -> Result<SelectData, ImapClientStdError>

Source

pub fn select_qresync( &mut self, mailbox: Mailbox<'static>, uid_validity: NonZeroU32, highest_mod_seq: u64, capability: &[Capability<'static>], ) -> Result<SelectData, ImapClientStdError>

SELECT <mailbox> (QRESYNC ...). Errors with QresyncNotSupported when capability lacks QRESYNC, with InvalidModSeq when highest_mod_seq is 0.

Source

pub fn close(&mut self) -> Result<(), ImapClientStdError>

Source

pub fn unselect(&mut self) -> Result<(), ImapClientStdError>

Source

pub fn check(&mut self) -> Result<(), ImapClientStdError>

Source

pub fn expunge(&mut self) -> Result<Vec<NonZeroU32>, ImapClientStdError>

EXPUNGE; returns the expunged sequence numbers.

Source

pub fn watch_mailbox( self, mailbox: Mailbox<'static>, capability: &[Capability<'static>], ) -> Result<ImapMailboxWatchStream, ImapClientStdError>

Consumes the client into a background watcher. Drop the returned stream (or call its close) to wind down. Errors when capability lacks QRESYNC.

Source

pub fn fetch( &mut self, sequence_set: SequenceSet, items: MacroOrMessageDataItemNames<'static>, uid: bool, ) -> Result<BTreeMap<NonZeroU32, Vec1<MessageDataItem<'static>>>, ImapClientStdError>

Source

pub fn search( &mut self, criteria: Vec1<SearchKey<'static>>, uid: bool, ) -> Result<Vec<NonZeroU32>, ImapClientStdError>

Source

pub fn store( &mut self, sequence_set: SequenceSet, kind: StoreType, flags: Vec<Flag<'static>>, uid: bool, ) -> Result<BTreeMap<NonZeroU32, Vec1<MessageDataItem<'static>>>, ImapClientStdError>

STORE (echo variant); returns the server-reported FETCH echoes.

Source

pub fn copy( &mut self, sequence_set: SequenceSet, mailbox: Mailbox<'static>, uid: bool, ) -> Result<ImapCopyUid, ImapClientStdError>

Source

pub fn move( &mut self, sequence_set: SequenceSet, mailbox: Mailbox<'static>, uid: bool, ) -> Result<ImapCopyUid, ImapClientStdError>

Source

pub fn append( &mut self, mailbox: Mailbox<'static>, flags: Vec<Flag<'static>>, date: Option<DateTime>, message: LiteralOrLiteral8<'static>, ) -> Result<ImapAppendOutput, ImapClientStdError>

APPEND; returns the optional EXISTS count and APPENDUID pair.

Source

pub fn sort( &mut self, sort_criteria: Vec1<SortCriterion>, search_criteria: Vec1<SearchKey<'static>>, uid: bool, ) -> Result<Vec<NonZeroU32>, ImapClientStdError>

Source

pub fn thread( &mut self, algorithm: ThreadingAlgorithm<'static>, search_criteria: Vec1<SearchKey<'static>>, uid: bool, ) -> Result<Vec<Thread>, ImapClientStdError>

Source§

impl ImapClientStd

Source

pub fn connect( url: &Url, tls: &Tls, starttls: bool, sasl: Option<impl Into<Sasl>>, auto_id: Option<Vec<(IString<'static>, NString<'static>)>>, ) -> Result<(Self, Vec<Capability<'static>>), ImapClientStdError>

Available on crate features native-tls or rustls-aws or rustls-ring only.

End-to-end connect: TCP/TLS, optional STARTTLS, greeting, optional SASL. imap:// is plain TCP (143), imaps:// is implicit TLS (993). starttls = true is only valid on imap://. Pass Sasl::None to skip auth.

Trait Implementations§

Source§

impl Debug for ImapClientStd

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V