Struct Client

Source
pub struct Client {
    pub state: Client,
    pub stream: Stream<MaybeTlsStream>,
    /* private fields */
}

Fields§

§state: Client§stream: Stream<MaybeTlsStream>

Implementations§

Source§

impl Client

Client constructors.

This section defines 3 public constructors for Client: insecure, tls and starttls.

Source

pub async fn insecure( host: impl ToString, port: u16, ) -> Result<Self, ClientError>

Creates an insecure client, using TCP.

This constructor creates a client based on an raw TcpStream, receives greeting then saves server capabilities.

Source§

impl Client

Client low-level API.

This section defines the low-level API of the client, by exposing convenient wrappers around Tasks. They do not contain any logic.

Source

pub async fn resolve<T: Task>( &mut self, task: T, ) -> Result<T::Output, ClientError>

Resolves the given Task.

Source

pub async fn enable( &mut self, capabilities: impl IntoIterator<Item = CapabilityEnable<'_>>, ) -> Result<Option<Vec<CapabilityEnable<'_>>>, ClientError>

Enables the given capabilities.

Source

pub async fn create( &mut self, mailbox: impl TryInto<Mailbox<'_>, Error = ValidationError>, ) -> Result<(), ClientError>

Creates a new mailbox.

Source

pub async fn list( &mut self, mailbox: impl TryInto<Mailbox<'_>, Error = ValidationError>, mailbox_wildcard: impl TryInto<ListMailbox<'_>, Error = ValidationError>, ) -> Result<Vec<(Mailbox<'static>, Option<QuotedChar>, Vec<FlagNameAttribute<'static>>)>, ClientError>

Lists mailboxes.

Source

pub async fn select( &mut self, mailbox: impl TryInto<Mailbox<'_>, Error = ValidationError>, ) -> Result<SelectDataUnvalidated, ClientError>

Selects the given mailbox.

Source

pub async fn examine( &mut self, mailbox: impl TryInto<Mailbox<'_>, Error = ValidationError>, ) -> Result<SelectDataUnvalidated, ClientError>

Selects the given mailbox in read-only mode.

Source

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

Expunges the selected mailbox.

A mailbox needs to be selected before, otherwise this function will fail.

Source

pub async fn delete( &mut self, mailbox: impl TryInto<Mailbox<'_>, Error = ValidationError>, ) -> Result<(), ClientError>

Deletes the given mailbox.

Source

pub async fn search( &mut self, criteria: impl IntoIterator<Item = SearchKey<'_>>, ) -> Result<Vec<NonZeroU32>, ClientError>

Searches messages matching the given criteria.

This function returns sequence numbers, if you need UID see Client::uid_search.

Searches messages matching the given criteria.

This function returns UIDs, if you need sequence numbers see Client::search.

Source

pub async fn sort( &mut self, sort_criteria: impl IntoIterator<Item = SortCriterion>, search_criteria: impl IntoIterator<Item = SearchKey<'_>>, ) -> Result<Vec<NonZeroU32>, ClientError>

Searches messages matching the given search criteria, sorted by the given sort criteria.

This function returns sequence numbers, if you need UID see Client::uid_sort.

Source

pub async fn uid_sort( &mut self, sort_criteria: impl IntoIterator<Item = SortCriterion>, search_criteria: impl IntoIterator<Item = SearchKey<'_>>, ) -> Result<Vec<NonZeroU32>, ClientError>

Searches messages matching the given search criteria, sorted by the given sort criteria.

This function returns UIDs, if you need sequence numbers see Client::sort.

Source

pub async fn thread( &mut self, algorithm: ThreadingAlgorithm<'_>, search_criteria: impl IntoIterator<Item = SearchKey<'_>>, ) -> Result<Vec<Thread>, ClientError>

Source

pub async fn uid_thread( &mut self, algorithm: ThreadingAlgorithm<'_>, search_criteria: impl IntoIterator<Item = SearchKey<'_>>, ) -> Result<Vec<Thread>, ClientError>

Source

pub async fn store( &mut self, sequence_set: SequenceSet, kind: StoreType, flags: impl IntoIterator<Item = Flag<'_>>, ) -> Result<HashMap<NonZeroU32, Vec1<MessageDataItem<'static>>>, ClientError>

Source

pub async fn uid_store( &mut self, sequence_set: SequenceSet, kind: StoreType, flags: impl IntoIterator<Item = Flag<'_>>, ) -> Result<HashMap<NonZeroU32, Vec1<MessageDataItem<'static>>>, ClientError>

Source

pub async fn silent_store( &mut self, sequence_set: SequenceSet, kind: StoreType, flags: impl IntoIterator<Item = Flag<'_>>, ) -> Result<(), ClientError>

Source

pub async fn uid_silent_store( &mut self, sequence_set: SequenceSet, kind: StoreType, flags: impl IntoIterator<Item = Flag<'_>>, ) -> Result<(), ClientError>

Source

pub async fn post_append_noop(&mut self) -> Result<Option<u32>, ClientError>

Source

pub async fn post_append_check(&mut self) -> Result<Option<u32>, ClientError>

Source

pub async fn fetch_first( &mut self, id: NonZeroU32, items: MacroOrMessageDataItemNames<'_>, ) -> Result<Vec1<MessageDataItem<'static>>, ClientError>

Source

pub async fn uid_fetch_first( &mut self, id: NonZeroU32, items: MacroOrMessageDataItemNames<'_>, ) -> Result<Vec1<MessageDataItem<'static>>, ClientError>

Source

pub async fn copy( &mut self, sequence_set: SequenceSet, mailbox: impl TryInto<Mailbox<'_>, Error = ValidationError>, ) -> Result<(), ClientError>

Source

pub async fn uid_copy( &mut self, sequence_set: SequenceSet, mailbox: impl TryInto<Mailbox<'_>, Error = ValidationError>, ) -> Result<(), ClientError>

Source

pub async fn move( &mut self, sequence_set: SequenceSet, mailbox: impl TryInto<Mailbox<'_>, Error = ValidationError>, ) -> Result<(), ClientError>

Source

pub async fn uid_move( &mut self, sequence_set: SequenceSet, mailbox: impl TryInto<Mailbox<'_>, Error = ValidationError>, ) -> Result<(), ClientError>

Source

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

Executes the CHECK command.

Source

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

Executes the NOOP command.

Source§

impl Client

Client medium-level API.

This section defines the medium-level API of the client (based on the low-level one), by exposing helpers that update client state and use a small amount of logic (mostly conditional code depending on available server capabilities).

Source

pub async fn refresh_capabilities(&mut self) -> Result<(), ClientError>

Fetches server capabilities, then saves them.

Source

pub async fn login( &mut self, username: impl TryInto<AString<'_>, Error = ValidationError>, password: impl TryInto<AString<'_>, Error = ValidationError>, ) -> Result<(), ClientError>

Identifies the user using the given username and password.

Source

pub async fn authenticate_plain( &mut self, login: impl AsRef<str>, password: impl AsRef<str>, ) -> Result<(), ClientError>

Authenticates the user using the PLAIN mechanism.

Source

pub async fn authenticate_xoauth2( &mut self, login: impl AsRef<str>, token: impl AsRef<str>, ) -> Result<(), ClientError>

Authenticates the user using the XOAUTH2 mechanism.

Source

pub async fn authenticate_oauthbearer( &mut self, user: impl AsRef<str>, host: impl AsRef<str>, port: u16, token: impl AsRef<str>, ) -> Result<(), ClientError>

Authenticates the user using the OAUTHBEARER mechanism.

Source

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

Exchanges client/server ids.

If the server does not support the ID extension, this function has no effect.

Source

pub async fn append( &mut self, mailbox: impl TryInto<Mailbox<'_>, Error = ValidationError>, flags: impl IntoIterator<Item = Flag<'_>>, message: impl AsRef<[u8]>, ) -> Result<Option<u32>, ClientError>

Source

pub async fn appenduid( &mut self, mailbox: impl TryInto<Mailbox<'_>, Error = ValidationError>, flags: impl IntoIterator<Item = Flag<'_>>, message: impl AsRef<[u8]>, ) -> Result<Option<(NonZeroU32, NonZeroU32)>, ClientError>

Source§

impl Client

Client high-level API.

This section defines the high-level API of the client (based on the low and medium ones), by exposing opinionated helpers. They contain more logic, and make use of fallbacks depending on available server capabilities.

Source

pub async fn fetch( &mut self, sequence_set: SequenceSet, items: MacroOrMessageDataItemNames<'_>, ) -> Result<HashMap<NonZeroU32, Vec1<MessageDataItem<'static>>>, ClientError>

Source

pub async fn uid_fetch( &mut self, sequence_set: SequenceSet, items: MacroOrMessageDataItemNames<'_>, ) -> Result<HashMap<NonZeroU32, Vec1<MessageDataItem<'static>>>, ClientError>

Source

pub async fn sort_or_fallback( &mut self, sort_criteria: impl IntoIterator<Item = SortCriterion> + Clone, search_criteria: impl IntoIterator<Item = SearchKey<'_>>, fetch_items: MacroOrMessageDataItemNames<'_>, ) -> Result<Vec<Vec1<MessageDataItem<'static>>>, ClientError>

Source

pub async fn uid_sort_or_fallback( &mut self, sort_criteria: impl IntoIterator<Item = SortCriterion> + Clone, search_criteria: impl IntoIterator<Item = SearchKey<'_>>, fetch_items: MacroOrMessageDataItemNames<'_>, ) -> Result<Vec<Vec1<MessageDataItem<'static>>>, ClientError>

Source

pub async fn appenduid_or_fallback( &mut self, mailbox: impl TryInto<Mailbox<'_>, Error = ValidationError> + Clone, flags: impl IntoIterator<Item = Flag<'_>>, message: impl AsRef<[u8]>, ) -> Result<Option<NonZeroU32>, ClientError>

Source

pub async fn move_or_fallback( &mut self, sequence_set: SequenceSet, mailbox: impl TryInto<Mailbox<'_>, Error = ValidationError>, ) -> Result<(), ClientError>

Source

pub async fn uid_move_or_fallback( &mut self, sequence_set: SequenceSet, mailbox: impl TryInto<Mailbox<'_>, Error = ValidationError>, ) -> Result<(), ClientError>

Source

pub fn enqueue_idle(&mut self) -> Tag<'static>

Source

pub async fn idle(&mut self, tag: Tag<'static>) -> Result<(), Error<NextError>>

Source

pub async fn idle_done( &mut self, tag: Tag<'static>, ) -> Result<(), Error<NextError>>

Auto Trait Implementations§

§

impl !Freeze for Client

§

impl !RefUnwindSafe for Client

§

impl Send for Client

§

impl !Sync for Client

§

impl Unpin for Client

§

impl !UnwindSafe for Client

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more