pub struct Client {
pub state: Client,
pub stream: Stream<MaybeTlsStream>,
/* private fields */
}
Fields§
§state: Client
§stream: Stream<MaybeTlsStream>
Implementations§
Source§impl Client
Client constructors.
impl Client
Client constructors.
This section defines 3 public constructors for Client
:
insecure
, tls
and starttls
.
Source§impl Client
Client low-level API.
impl Client
Client low-level API.
This section defines the low-level API of the client, by exposing
convenient wrappers around Task
s. They do not contain any
logic.
Sourcepub async fn resolve<T: Task>(
&mut self,
task: T,
) -> Result<T::Output, ClientError>
pub async fn resolve<T: Task>( &mut self, task: T, ) -> Result<T::Output, ClientError>
Resolves the given Task
.
Sourcepub async fn enable(
&mut self,
capabilities: impl IntoIterator<Item = CapabilityEnable<'_>>,
) -> Result<Option<Vec<CapabilityEnable<'_>>>, ClientError>
pub async fn enable( &mut self, capabilities: impl IntoIterator<Item = CapabilityEnable<'_>>, ) -> Result<Option<Vec<CapabilityEnable<'_>>>, ClientError>
Enables the given capabilities.
Sourcepub async fn create(
&mut self,
mailbox: impl TryInto<Mailbox<'_>, Error = ValidationError>,
) -> Result<(), ClientError>
pub async fn create( &mut self, mailbox: impl TryInto<Mailbox<'_>, Error = ValidationError>, ) -> Result<(), ClientError>
Creates a new mailbox.
Sourcepub 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>
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.
Sourcepub async fn select(
&mut self,
mailbox: impl TryInto<Mailbox<'_>, Error = ValidationError>,
) -> Result<SelectDataUnvalidated, ClientError>
pub async fn select( &mut self, mailbox: impl TryInto<Mailbox<'_>, Error = ValidationError>, ) -> Result<SelectDataUnvalidated, ClientError>
Selects the given mailbox.
Sourcepub async fn examine(
&mut self,
mailbox: impl TryInto<Mailbox<'_>, Error = ValidationError>,
) -> Result<SelectDataUnvalidated, ClientError>
pub async fn examine( &mut self, mailbox: impl TryInto<Mailbox<'_>, Error = ValidationError>, ) -> Result<SelectDataUnvalidated, ClientError>
Selects the given mailbox in read-only mode.
Sourcepub async fn expunge(&mut self) -> Result<Vec<NonZeroU32>, ClientError>
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.
Sourcepub async fn delete(
&mut self,
mailbox: impl TryInto<Mailbox<'_>, Error = ValidationError>,
) -> Result<(), ClientError>
pub async fn delete( &mut self, mailbox: impl TryInto<Mailbox<'_>, Error = ValidationError>, ) -> Result<(), ClientError>
Deletes the given mailbox.
Sourcepub async fn search(
&mut self,
criteria: impl IntoIterator<Item = SearchKey<'_>>,
) -> Result<Vec<NonZeroU32>, ClientError>
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
.
Sourcepub async fn uid_search(
&mut self,
criteria: impl IntoIterator<Item = SearchKey<'_>>,
) -> Result<Vec<NonZeroU32>, ClientError>
pub async fn uid_search( &mut self, criteria: impl IntoIterator<Item = SearchKey<'_>>, ) -> Result<Vec<NonZeroU32>, ClientError>
Searches messages matching the given criteria.
This function returns UIDs, if you need sequence numbers see
Client::search
.
Sourcepub async fn sort(
&mut self,
sort_criteria: impl IntoIterator<Item = SortCriterion>,
search_criteria: impl IntoIterator<Item = SearchKey<'_>>,
) -> Result<Vec<NonZeroU32>, ClientError>
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
.
Sourcepub async fn uid_sort(
&mut self,
sort_criteria: impl IntoIterator<Item = SortCriterion>,
search_criteria: impl IntoIterator<Item = SearchKey<'_>>,
) -> Result<Vec<NonZeroU32>, ClientError>
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
.
pub async fn thread( &mut self, algorithm: ThreadingAlgorithm<'_>, search_criteria: impl IntoIterator<Item = SearchKey<'_>>, ) -> Result<Vec<Thread>, ClientError>
pub async fn uid_thread( &mut self, algorithm: ThreadingAlgorithm<'_>, search_criteria: impl IntoIterator<Item = SearchKey<'_>>, ) -> Result<Vec<Thread>, ClientError>
pub async fn store( &mut self, sequence_set: SequenceSet, kind: StoreType, flags: impl IntoIterator<Item = Flag<'_>>, ) -> Result<HashMap<NonZeroU32, Vec1<MessageDataItem<'static>>>, ClientError>
pub async fn uid_store( &mut self, sequence_set: SequenceSet, kind: StoreType, flags: impl IntoIterator<Item = Flag<'_>>, ) -> Result<HashMap<NonZeroU32, Vec1<MessageDataItem<'static>>>, ClientError>
pub async fn silent_store( &mut self, sequence_set: SequenceSet, kind: StoreType, flags: impl IntoIterator<Item = Flag<'_>>, ) -> Result<(), ClientError>
pub async fn uid_silent_store( &mut self, sequence_set: SequenceSet, kind: StoreType, flags: impl IntoIterator<Item = Flag<'_>>, ) -> Result<(), ClientError>
pub async fn post_append_noop(&mut self) -> Result<Option<u32>, ClientError>
pub async fn post_append_check(&mut self) -> Result<Option<u32>, ClientError>
pub async fn fetch_first( &mut self, id: NonZeroU32, items: MacroOrMessageDataItemNames<'_>, ) -> Result<Vec1<MessageDataItem<'static>>, ClientError>
pub async fn uid_fetch_first( &mut self, id: NonZeroU32, items: MacroOrMessageDataItemNames<'_>, ) -> Result<Vec1<MessageDataItem<'static>>, ClientError>
pub async fn copy( &mut self, sequence_set: SequenceSet, mailbox: impl TryInto<Mailbox<'_>, Error = ValidationError>, ) -> Result<(), ClientError>
pub async fn uid_copy( &mut self, sequence_set: SequenceSet, mailbox: impl TryInto<Mailbox<'_>, Error = ValidationError>, ) -> Result<(), ClientError>
pub async fn move( &mut self, sequence_set: SequenceSet, mailbox: impl TryInto<Mailbox<'_>, Error = ValidationError>, ) -> Result<(), ClientError>
pub async fn uid_move( &mut self, sequence_set: SequenceSet, mailbox: impl TryInto<Mailbox<'_>, Error = ValidationError>, ) -> Result<(), ClientError>
Sourcepub async fn check(&mut self) -> Result<(), ClientError>
pub async fn check(&mut self) -> Result<(), ClientError>
Executes the CHECK
command.
Sourcepub async fn noop(&mut self) -> Result<(), ClientError>
pub async fn noop(&mut self) -> Result<(), ClientError>
Executes the NOOP
command.
Source§impl Client
Client medium-level API.
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).
Sourcepub async fn refresh_capabilities(&mut self) -> Result<(), ClientError>
pub async fn refresh_capabilities(&mut self) -> Result<(), ClientError>
Fetches server capabilities, then saves them.
Sourcepub async fn login(
&mut self,
username: impl TryInto<AString<'_>, Error = ValidationError>,
password: impl TryInto<AString<'_>, Error = ValidationError>,
) -> Result<(), ClientError>
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.
Sourcepub async fn authenticate_plain(
&mut self,
login: impl AsRef<str>,
password: impl AsRef<str>,
) -> Result<(), ClientError>
pub async fn authenticate_plain( &mut self, login: impl AsRef<str>, password: impl AsRef<str>, ) -> Result<(), ClientError>
Authenticates the user using the PLAIN
mechanism.
Sourcepub async fn authenticate_xoauth2(
&mut self,
login: impl AsRef<str>,
token: impl AsRef<str>,
) -> Result<(), ClientError>
pub async fn authenticate_xoauth2( &mut self, login: impl AsRef<str>, token: impl AsRef<str>, ) -> Result<(), ClientError>
Authenticates the user using the XOAUTH2
mechanism.
Sourcepub async fn authenticate_oauthbearer(
&mut self,
user: impl AsRef<str>,
host: impl AsRef<str>,
port: u16,
token: impl AsRef<str>,
) -> Result<(), ClientError>
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.
Sourcepub async fn id(
&mut self,
params: Option<Vec<(IString<'static>, NString<'static>)>>,
) -> Result<Option<Vec<(IString<'static>, NString<'static>)>>, ClientError>
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.
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>
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.
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.