session: rename SessionOutput to SessionInput

This commit is contained in:
Astro 2020-09-30 23:35:11 +02:00
parent bfdb64ffd6
commit d4e7036fab
2 changed files with 10 additions and 10 deletions

View File

@ -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(_) =>

View File

@ -38,16 +38,16 @@ impl LineReader {
}
}
pub enum SessionOutput {
pub enum SessionInput {
Nothing,
Command(Command),
Error(ParserError),
}
impl From<Result<Command, ParserError>> for SessionOutput {
impl From<Result<Command, ParserError>> for SessionInput {
fn from(input: Result<Command, ParserError>) -> 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)
}
}