diff --git a/src/main.rs b/src/main.rs index 05b503d..9785d83 100644 --- a/src/main.rs +++ b/src/main.rs @@ -54,7 +54,7 @@ mod net; mod server; use server::Server; mod session; -use session::{Session, SessionOutput}; +use session::{Session, SessionInput}; mod command_parser; use command_parser::{Command, ShowCommand, PwmPin}; mod timer; @@ -196,8 +196,8 @@ fn main() -> ! { session.reset(); } else if socket.can_send() && socket.can_recv() && socket.send_capacity() - socket.send_queue() > 1024 { match socket.recv(|buf| session.feed(buf)) { - Ok(SessionOutput::Nothing) => {} - Ok(SessionOutput::Command(command)) => match command { + Ok(SessionInput::Nothing) => {} + Ok(SessionInput::Command(command)) => match command { Command::Quit => socket.close(), Command::Reporting(reporting) => { @@ -413,7 +413,7 @@ fn main() -> ! { SCB::sys_reset(); } } - Ok(SessionOutput::Error(e)) => { + Ok(SessionInput::Error(e)) => { let _ = writeln!(socket, "Command error: {:?}", e); } Err(_) => diff --git a/src/session.rs b/src/session.rs index 4e594b9..f9e25b0 100644 --- a/src/session.rs +++ b/src/session.rs @@ -38,16 +38,16 @@ impl LineReader { } } -pub enum SessionOutput { +pub enum SessionInput { Nothing, Command(Command), Error(ParserError), } -impl From> for SessionOutput { +impl From> for SessionInput { fn from(input: Result) -> Self { - input.map(SessionOutput::Command) - .unwrap_or_else(SessionOutput::Error) + input.map(SessionInput::Command) + .unwrap_or_else(SessionInput::Error) } } @@ -106,7 +106,7 @@ impl Session { self.report_pending[channel] = false; } - pub fn feed(&mut self, buf: &[u8]) -> (usize, SessionOutput) { + pub fn feed(&mut self, buf: &[u8]) -> (usize, SessionInput) { let mut buf_bytes = 0; for (i, b) in buf.iter().enumerate() { buf_bytes = i + 1; @@ -125,6 +125,6 @@ impl Session { None => {} } } - (buf_bytes, SessionOutput::Nothing) + (buf_bytes, SessionInput::Nothing) } }