Move mailbox to its own file
This commit is contained in:
parent
50a55d59c4
commit
625fb09c8b
4 changed files with 28 additions and 25 deletions
|
|
@ -2,7 +2,8 @@ extern crate imap;
|
|||
extern crate openssl;
|
||||
|
||||
use openssl::ssl::{SslContext, SslMethod};
|
||||
use imap::client::{Client, Mailbox};
|
||||
use imap::client::Client;
|
||||
use imap::mailbox::Mailbox;
|
||||
|
||||
fn main() {
|
||||
let mut imap_socket = match Client::secure_connect(("imap.gmail.com", 993), SslContext::new(SslMethod::Sslv23).unwrap()) {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ use openssl::ssl::{SslContext, SslStream};
|
|||
use std::io::{Error, ErrorKind, Read, Result, Write};
|
||||
use regex::Regex;
|
||||
|
||||
use super::mailbox::Mailbox;
|
||||
|
||||
static TAG_PREFIX: &'static str = "a";
|
||||
const INITIAL_TAG: u32 = 0;
|
||||
|
||||
|
|
@ -12,30 +14,6 @@ pub struct Client<T> {
|
|||
tag: u32
|
||||
}
|
||||
|
||||
pub struct Mailbox {
|
||||
pub flags: String,
|
||||
pub exists: u32,
|
||||
pub recent: u32,
|
||||
pub unseen: Option<u32>,
|
||||
pub permanent_flags: Option<String>,
|
||||
pub uid_next: Option<u32>,
|
||||
pub uid_validity: Option<u32>
|
||||
}
|
||||
|
||||
impl Default for Mailbox {
|
||||
fn default() -> Mailbox {
|
||||
Mailbox {
|
||||
flags: "".to_string(),
|
||||
exists: 0,
|
||||
recent: 0,
|
||||
unseen: None,
|
||||
permanent_flags: None,
|
||||
uid_next: None,
|
||||
uid_validity: None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Client<TcpStream> {
|
||||
/// Creates a new client.
|
||||
pub fn connect<A: ToSocketAddrs>(addr: A) -> Result<Client<TcpStream>> {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ extern crate openssl;
|
|||
extern crate regex;
|
||||
|
||||
pub mod client;
|
||||
pub mod mailbox;
|
||||
|
||||
#[cfg(test)]
|
||||
mod mock_stream;
|
||||
|
|
|
|||
23
src/mailbox.rs
Normal file
23
src/mailbox.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
pub struct Mailbox {
|
||||
pub flags: String,
|
||||
pub exists: u32,
|
||||
pub recent: u32,
|
||||
pub unseen: Option<u32>,
|
||||
pub permanent_flags: Option<String>,
|
||||
pub uid_next: Option<u32>,
|
||||
pub uid_validity: Option<u32>
|
||||
}
|
||||
|
||||
impl Default for Mailbox {
|
||||
fn default() -> Mailbox {
|
||||
Mailbox {
|
||||
flags: "".to_string(),
|
||||
exists: 0,
|
||||
recent: 0,
|
||||
unseen: None,
|
||||
permanent_flags: None,
|
||||
uid_next: None,
|
||||
uid_validity: None
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue