Pop3Connection

Struct Pop3Connection 

Source
pub struct Pop3Connection { /* private fields */ }
Expand description

POP3 connection

Implementations§

Source§

impl Pop3Connection

Source

pub fn new(host: &str, port: u16) -> Result<Pop3Connection, Box<dyn Error>>

Returns a new POP3 connection.

§Arguments
  • host - IP-Address or host name of the POP3 server to connect
  • port - Port of the POP3 server to connect
Source

pub fn with_custom_certs( host: &str, port: u16, root_store: RootCertStore, ) -> Result<Pop3Connection, Box<dyn Error>>

Returns a new POP3 connection with custom certificates.

§Arguments
  • host - IP-Address or host name of the POP3 server to connect
  • port - Port of the POP3 server to connect
  • root_store - Store of trusted (root) certificates.
§Examples
use rust_pop3_client::Pop3Connection;
use rustls::RootCertStore;

let mut root_store = RootCertStore::empty();
for cert in rustls_native_certs::load_native_certs().unwrap() {
    root_store.add(&rustls::Certificate(cert.0)).unwrap();
}
 
let connection = Pop3Connection::with_custom_certs("", 995, root_store);
Source

pub fn login( &mut self, user: &str, password: &str, ) -> Result<(), Box<dyn Error>>

Authenticate a POP3 session using username and password.

This is usually the first set of commands after a POP3 session is established.

§Arguments
  • user - Name of the user, typically it’s e-mail address.
  • password - Password of the user.
Source

pub fn stat(&mut self) -> Result<Pop3Stat, Box<dyn Error>>

Returns maildrop statistics.

Source

pub fn list(&mut self) -> Result<Vec<Pop3MessageInfo>, Box<dyn Error>>

Returns id and size of each message.

Source

pub fn get_message_size( &mut self, message_id: u32, ) -> Result<u32, Box<dyn Error>>

Returns the size of a given message.

§Arguments
  • message_id - id of the message to query
Source

pub fn retrieve( &mut self, message_id: u32, writer: &mut impl Write, ) -> Result<(), Box<dyn Error>>

Downloads a given message.

§Arguments
  • message_id - id of the message to download
  • writer - writer to store message
Source

pub fn delete(&mut self, message_id: u32) -> Result<(), Box<dyn Error>>

Deletes a given message.

§Arguments
  • message_id - id of the message to download
Source

pub fn reset(&mut self) -> Result<(), Box<dyn Error>>

Unmark any messages marked as delete.

Source

pub fn top( &mut self, message_id: u32, line_count: u32, ) -> Result<String, Box<dyn Error>>

Returns the message header an a given number of lines from the message.

§Arguments
  • message_id - id of the message
  • line_count - count of lines to return from the message body
Source

pub fn list_unique_ids( &mut self, ) -> Result<Vec<Pop3MessageUidInfo>, Box<dyn Error>>

Returns the unique ids of all messages.

Source

pub fn get_unique_id( &mut self, message_id: u32, ) -> Result<String, Box<dyn Error>>

Returns the unique id of a given message.

§Arguments
  • message_id - id of the message

Trait Implementations§

Source§

impl Drop for Pop3Connection

Source§

fn drop(&mut self)

Closes POP3 connection on drop.

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<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, 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.