testing/imap_conn: update imapconn shell use
parent
504b658f68
commit
bce97d71bb
|
@ -250,6 +250,10 @@ pub trait MailBackend: ::std::fmt::Debug + Send + Sync {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
fn as_any(&self) -> &dyn Any;
|
fn as_any(&self) -> &dyn Any;
|
||||||
|
|
||||||
|
fn as_any_mut(&mut self) -> &mut dyn Any {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A `BackendOp` manages common operations for the various mail backends. They only live for the
|
/// A `BackendOp` manages common operations for the various mail backends. They only live for the
|
||||||
|
|
|
@ -471,6 +471,10 @@ impl MailBackend for ImapType {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn as_any_mut(&mut self) -> &mut dyn::std::any::Any {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
fn tags(&self) -> Option<Arc<RwLock<BTreeMap<u64, String>>>> {
|
fn tags(&self) -> Option<Arc<RwLock<BTreeMap<u64, String>>>> {
|
||||||
if *self.can_create_flags.lock().unwrap() {
|
if *self.can_create_flags.lock().unwrap() {
|
||||||
Some(self.tag_index.clone())
|
Some(self.tag_index.clone())
|
||||||
|
@ -530,8 +534,8 @@ impl ImapType {
|
||||||
pub fn shell(&mut self) {
|
pub fn shell(&mut self) {
|
||||||
let mut conn = ImapConnection::new_connection(&self.server_conf);
|
let mut conn = ImapConnection::new_connection(&self.server_conf);
|
||||||
let mut res = String::with_capacity(8 * 1024);
|
let mut res = String::with_capacity(8 * 1024);
|
||||||
|
conn.send_command(b"NOOP").unwrap();
|
||||||
conn.read_response(&mut res).unwrap();
|
conn.read_response(&mut res).unwrap();
|
||||||
debug!("out: {}", &res);
|
|
||||||
|
|
||||||
let mut input = String::new();
|
let mut input = String::new();
|
||||||
loop {
|
loop {
|
||||||
|
@ -540,6 +544,9 @@ impl ImapType {
|
||||||
|
|
||||||
match io::stdin().read_line(&mut input) {
|
match io::stdin().read_line(&mut input) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
|
if input.trim().eq_ignore_ascii_case("logout") {
|
||||||
|
break;
|
||||||
|
}
|
||||||
conn.send_command(input.as_bytes()).unwrap();
|
conn.send_command(input.as_bytes()).unwrap();
|
||||||
conn.read_lines(&mut res, String::new()).unwrap();
|
conn.read_lines(&mut res, String::new()).unwrap();
|
||||||
if input.trim() == "IDLE" {
|
if input.trim() == "IDLE" {
|
||||||
|
@ -550,9 +557,6 @@ impl ImapType {
|
||||||
conn = iter.into_conn();
|
conn = iter.into_conn();
|
||||||
}
|
}
|
||||||
debug!("out: {}", &res);
|
debug!("out: {}", &res);
|
||||||
if input.trim().eq_ignore_ascii_case("logout") {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Err(error) => debug!("error: {}", error),
|
Err(error) => debug!("error: {}", error),
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,11 @@ fn main() -> Result<()> {
|
||||||
.collect(),
|
.collect(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let mut imap = ImapType::new(&set, Box::new(|_| true));
|
let mut imap = ImapType::new(&set, Box::new(|_| true))?;
|
||||||
imap.shell();
|
|
||||||
|
(imap.as_any_mut())
|
||||||
|
.downcast_mut::<ImapType>()
|
||||||
|
.unwrap()
|
||||||
|
.shell();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue