Made it a library, as I should have done from the beginning
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
use structopt::StructOpt;
|
||||
use std::time::Duration;
|
||||
|
||||
mod tn3270;
|
||||
mod encoding;
|
||||
use tn3270s::tn3270;
|
||||
|
||||
#[derive(StructOpt)]
|
||||
pub struct Cli {
|
||||
@@ -43,7 +42,9 @@ fn main() -> anyhow::Result<()> {
|
||||
}
|
||||
};
|
||||
|
||||
run(session);
|
||||
if let Err(err) = run(session) {
|
||||
eprintln!("Error in session: {}", err);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
2
src/lib.rs
Normal file
2
src/lib.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
pub mod tn3270;
|
||||
mod encoding;
|
||||
@@ -7,7 +7,6 @@ use libtelnet_rs::{
|
||||
}
|
||||
};
|
||||
use std::net::TcpStream;
|
||||
use libtelnet_rs::telnet::op_option::EOR;
|
||||
use std::io::{Write, Read};
|
||||
use std::time::Duration;
|
||||
|
||||
@@ -124,14 +123,14 @@ impl Session {
|
||||
initial_negotiation.extend(self.parser._do(tn_opt::TTYPE));
|
||||
initial_negotiation.extend(self.parser._will(tn_opt::TTYPE));
|
||||
|
||||
self.process_events(initial_negotiation);
|
||||
self.process_events(initial_negotiation)?;
|
||||
|
||||
// Large enough for a TCP packet
|
||||
let mut idata = Vec::with_capacity(2000);
|
||||
idata.resize(idata.capacity(), 0);
|
||||
|
||||
// Make sure that negotiation completes quickly
|
||||
self.stream.set_read_timeout(Some(Duration::from_secs(5)));
|
||||
self.stream.set_read_timeout(Some(Duration::from_secs(5)))?;
|
||||
|
||||
while !self.is_ready() {
|
||||
let len = self.stream.read(&mut idata[..])?;
|
||||
@@ -143,6 +142,7 @@ impl Session {
|
||||
self.process_events(events)?;
|
||||
}
|
||||
|
||||
self.stream.set_read_timeout(None)?;
|
||||
Ok(true)
|
||||
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ bitflags! {
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Hash)]
|
||||
enum Transparency {
|
||||
pub enum Transparency {
|
||||
Default,
|
||||
Or,
|
||||
Xor,
|
||||
|
||||
Reference in New Issue
Block a user