refactor: split into more logical files
This commit is contained in:
parent
19eb943865
commit
9dc681086d
11 changed files with 728 additions and 276 deletions
29
src/protocols.rs
Normal file
29
src/protocols.rs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
mod binary_protocol;
|
||||
mod text_protocol;
|
||||
|
||||
use std::io;
|
||||
|
||||
pub use binary_protocol::BinaryParser;
|
||||
pub use text_protocol::TextParser;
|
||||
use tokio::io::AsyncWriteExt;
|
||||
|
||||
use crate::{Canvas, Command, Response};
|
||||
|
||||
pub trait Parser<R>
|
||||
where
|
||||
R: std::marker::Unpin + tokio::io::AsyncBufRead,
|
||||
{
|
||||
async fn parse(&self, reader: &mut R) -> io::Result<Command>;
|
||||
}
|
||||
|
||||
pub trait IOProtocol {
|
||||
fn change_canvas(&mut self, canvas: Canvas) -> io::Result<()>;
|
||||
}
|
||||
|
||||
pub trait Responder<W>
|
||||
where
|
||||
W: AsyncWriteExt + std::marker::Unpin,
|
||||
{
|
||||
async fn unparse(&self, response: Response, writer: &mut W) -> io::Result<()>;
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue