pub struct Pop3Connection { /* private fields */ }
Expand description
POP3 connection
Implementations§
Source§impl Pop3Connection
impl Pop3Connection
Sourcepub fn new(host: &str, port: u16) -> Result<Pop3Connection, Box<dyn Error>>
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 connectport
- Port of the POP3 server to connect
Sourcepub fn with_custom_certs(
host: &str,
port: u16,
root_store: RootCertStore,
) -> Result<Pop3Connection, Box<dyn Error>>
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 connectport
- Port of the POP3 server to connectroot_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);
Sourcepub fn login(
&mut self,
user: &str,
password: &str,
) -> Result<(), Box<dyn Error>>
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.
Sourcepub fn list(&mut self) -> Result<Vec<Pop3MessageInfo>, Box<dyn Error>>
pub fn list(&mut self) -> Result<Vec<Pop3MessageInfo>, Box<dyn Error>>
Returns id and size of each message.
Sourcepub fn retrieve(
&mut self,
message_id: u32,
writer: &mut impl Write,
) -> Result<(), Box<dyn Error>>
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 downloadwriter
- writer to store message
Sourcepub fn top(
&mut self,
message_id: u32,
line_count: u32,
) -> Result<String, Box<dyn Error>>
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 messageline_count
- count of lines to return from the message body
Sourcepub fn list_unique_ids(
&mut self,
) -> Result<Vec<Pop3MessageUidInfo>, Box<dyn Error>>
pub fn list_unique_ids( &mut self, ) -> Result<Vec<Pop3MessageUidInfo>, Box<dyn Error>>
Returns the unique ids of all messages.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Pop3Connection
impl !RefUnwindSafe for Pop3Connection
impl Send for Pop3Connection
impl Sync for Pop3Connection
impl Unpin for Pop3Connection
impl !UnwindSafe for Pop3Connection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more