pub struct Client<S: AsyncWrite + AsyncRead + Unpin> { /* private fields */ }
Implementations§
source§impl<S: AsyncRead + AsyncWrite + Unpin> Client<S>
impl<S: AsyncRead + AsyncWrite + Unpin> Client<S>
pub fn inner(&self) -> &Option<Socket<S>>
pub fn into_inner(self) -> Option<Socket<S>>
sourcepub fn get_state(&self) -> &ClientState
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
sourcepub async fn noop(&mut self) -> Result<()>
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
sourcepub async fn uidl(
&mut self,
msg_number: Option<u32>
) -> Result<UniqueIDResponse>
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
pub async fn top(&mut self, msg_number: u32, lines: u32) -> Result<Vec<u8>>
sourcepub fn is_deleted(&mut self, msg_number: &u32) -> bool
pub fn is_deleted(&mut self, msg_number: &u32) -> bool
sourcepub async fn dele(&mut self, msg_number: u32) -> Result<()>
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);
sourcepub async fn rset(&mut self) -> Result<()>
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
sourcepub async fn retr(&mut self, msg_number: u32) -> Result<Vec<u8>>
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
pub async fn list(&mut self, msg_number: Option<u32>) -> Result<StatsResponse>
pub async fn stat(&mut self) -> Result<Stats>
pub async fn apop(&mut self, name: &str, digest: &str) -> Result<()>
pub async fn auth<U: AsRef<str>>(&mut self, token: U) -> Result<()>
pub async fn login<U: AsRef<str>, P: AsRef<str>>( &mut self, user: U, password: P ) -> Result<()>
sourcepub async fn quit(&mut self) -> Result<()>
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
sourcepub fn has_capability(&mut self, capabilities: Vec<Capability>) -> bool
pub fn has_capability(&mut self, capabilities: Vec<Capability>) -> bool
Check whether the server supports one of the given capabilities.
sourcepub fn capabilities(&self) -> &Capabilities
pub fn capabilities(&self) -> &Capabilities
Returns the current list of capabilities given by the server.
sourcepub async fn capa(&mut self) -> Result<Capabilities>
pub async fn capa(&mut self) -> Result<Capabilities>
Fetches a list of capabilities for the currently connected server and returns it.