Struct async_pop::Client

source ·
pub struct Client<S: AsyncWrite + AsyncRead + Unpin> { /* private fields */ }

Implementations§

source§

impl<S: AsyncRead + AsyncWrite + Unpin> Client<S>

source

pub fn inner(&self) -> &Option<Socket<S>>

source

pub fn into_inner(self) -> Option<Socket<S>>

source

pub fn get_state(&self) -> &ClientState

Current client state

Indicates what state the client is currently in, can be either Authentication, Transaction, Update or None.

Some methods are only available in some specified states and will error if run in an incorrect state.

https://www.rfc-editor.org/rfc/rfc1939#section-3

source

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

NOOP

The POP3 server does nothing, it merely replies with a positive response.

Arguments: none
Restrictions:
  • May only be given in the TRANSACTION state
Possible Responses:
  • OK
Examples:
client.noop()?;

https://www.rfc-editor.org/rfc/rfc1939#page-9

source

pub async fn uidl( &mut self, msg_number: Option<u32> ) -> Result<UniqueIDResponse>

UIDL

If an argument was given and the POP3 server issues a positive response with a line containing information for that message. This line is called a “unique-id listing” for that message.

If no argument was given and the POP3 server issues a positive response, then the response given is multi-line. After the initial +OK, for each message in the maildrop, the POP3 server responds with a line containing information for that message. This line is called a “unique-id listing” for that message.

Arguments:
  • a message-number (optional), which, if present, may NOT refer to a message marked as deleted.
Restrictions:
  • May only be given in the TRANSACTION state.
Possible responses:
  • +OK unique-id listing follows
  • -ERR no such message

https://www.rfc-editor.org/rfc/rfc1939#page-12

source

pub async fn top(&mut self, msg_number: u32, lines: u32) -> Result<Vec<u8>>

source

pub fn is_deleted(&mut self, msg_number: &u32) -> bool

Check whether a given message is marked as deleted by the server.

If this function returns true then the message may still not exist.

Examples:
let msg_number: u32 = 8;
let is_deleted = client.is_deleted(msg_number);
assert_eq!(is_deleted, false);
source

pub async fn dele(&mut self, msg_number: u32) -> Result<()>

DELE

The POP3 server marks the message as deleted. Any future reference to the message-number associated with the message in a POP3 command generates an error. The POP3 server does not actually delete the message until the POP3 session enters the UPDATE state.

Arguments:
  • a message-number (required) which may NOT refer to a message marked as deleted.
Restrictions:
  • may only be given in the TRANSACTION state
Possible Responses:
  • OK: message deleted
  • ERR: no such message
Examples
let msg_number: u32 = 8;
let is_deleted = client.is_deleted(msg_number);

println!("{}", is_deleted);
source

pub async fn rset(&mut self) -> Result<()>

RSET

If any messages have been marked as deleted by the POP3 server, they are unmarked.

Arguments: none
Restrictions:
  • May only be given in the TRANSACTION state
Possible Responses:
  • +OK
Examples:
client.rset().unwrap();

https://www.rfc-editor.org/rfc/rfc1939#page-9

source

pub async fn retr(&mut self, msg_number: u32) -> Result<Vec<u8>>

RETR

Retrieves the full RFC822 compliant message from the server and returns it as a byte vector

Arguments:
  • A message-number (required) which may NOT refer to a message marked as deleted
Restrictions:
  • May only be given in the TRANSACTION state
Possible Responses:
  • OK: message follows
  • ERR: no such message
Examples
extern crate mailparse;
use mailparse::parse_mail;

let response = client.retr(1).unwrap();

let parsed = parse_mail(&response);

let subject = parsed.headers.get_first_value("Subject").unwrap();

println!("{}", subject);

https://www.rfc-editor.org/rfc/rfc1939#page-8

source

pub async fn list(&mut self, msg_number: Option<u32>) -> Result<StatsResponse>

source

pub async fn stat(&mut self) -> Result<Stats>

source

pub async fn apop(&mut self, name: &str, digest: &str) -> Result<()>

source

pub async fn auth<U: AsRef<str>>(&mut self, token: U) -> Result<()>

source

pub async fn login<U: AsRef<str>, P: AsRef<str>>( &mut self, user: U, password: P ) -> Result<()>

source

pub async fn quit(&mut self) -> Result<()>

QUIT

Quits the session

Arguments: none
Restrictions: none
Possible Responses:
  • +OK

https://www.rfc-editor.org/rfc/rfc1939#page-5

source

pub fn has_capability(&mut self, capabilities: Vec<Capability>) -> bool

Check whether the server supports one of the given capabilities.

source

pub fn capabilities(&self) -> &Capabilities

Returns the current list of capabilities given by the server.

source

pub async fn capa(&mut self) -> Result<Capabilities>

Fetches a list of capabilities for the currently connected server and returns it.

source

pub fn greeting(&self) -> Option<&str>

The greeting that the POP server sent when the connection opened.

Auto Trait Implementations§

§

impl<S> RefUnwindSafe for Client<S>where S: RefUnwindSafe,

§

impl<S> Send for Client<S>where S: Send,

§

impl<S> Sync for Client<S>where S: Sync,

§

impl<S> Unpin for Client<S>

§

impl<S> UnwindSafe for Client<S>where S: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.