Reorganize and refactor, adding integration test for common library stuff

This commit is contained in:
Barry Pederson
2024-11-03 11:44:03 -08:00
parent 00743fbe9c
commit 5f4a0e0e88
9 changed files with 148 additions and 82 deletions
+6 -3
View File
@@ -1,16 +1,19 @@
use crate::repository::PasswordDirectory;
use common::{Request, RESPONSE_NO, RESPONSE_OK};
use common::request::Request;
use std::io::{Error, Write};
use std::os::unix::net::UnixStream;
pub const RESPONSE_NO: [u8; 4] = [0x0, 0x2, b'N', b'O'];
pub const RESPONSE_OK: [u8; 4] = [0x0, 0x2, b'O', b'K'];
pub struct Handler {
stream: UnixStream,
handler: PasswordDirectory,
}
impl Handler {
pub fn new(stream: UnixStream, handler: PasswordDirectory) -> Result<Handler, Error> {
Ok(Handler { stream, handler })
pub fn new(stream: UnixStream, handler: PasswordDirectory) -> Handler {
Handler { stream, handler }
}
fn communicate(&mut self) -> Result<(), Error> {