Rename server.rs to handler.rs for clarity, since this is responsible for handling one interaction with a client

This commit is contained in:
Barry Pederson
2024-11-03 10:31:31 -08:00
parent 1a66c8ede5
commit 7cd2ba3364
3 changed files with 7 additions and 7 deletions
@@ -3,14 +3,14 @@ use common::{Request, RESPONSE_NO, RESPONSE_OK};
use std::io::{Error, Write}; use std::io::{Error, Write};
use std::os::unix::net::UnixStream; use std::os::unix::net::UnixStream;
pub struct Server { pub struct Handler {
stream: UnixStream, stream: UnixStream,
handler: PasswordDirectory, handler: PasswordDirectory,
} }
impl Server { impl Handler {
pub fn new(stream: UnixStream, handler: PasswordDirectory) -> Result<Server, Error> { pub fn new(stream: UnixStream, handler: PasswordDirectory) -> Result<Handler, Error> {
Ok(Server { stream, handler }) Ok(Handler { stream, handler })
} }
fn communicate(&mut self) -> Result<(), Error> { fn communicate(&mut self) -> Result<(), Error> {
+2 -2
View File
@@ -1,6 +1,6 @@
use crate::handler::Handler;
use crate::options::OPTIONS; use crate::options::OPTIONS;
use crate::repository::PasswordDirectory; use crate::repository::PasswordDirectory;
use crate::server::Server;
use std::fs::{metadata, set_permissions}; use std::fs::{metadata, set_permissions};
use std::io::Error; use std::io::Error;
use std::os::unix::fs::PermissionsExt; use std::os::unix::fs::PermissionsExt;
@@ -34,7 +34,7 @@ impl Listener {
Ok(stream) => { Ok(stream) => {
/* connection succeeded */ /* connection succeeded */
let handler = self.handler.clone(); let handler = self.handler.clone();
thread::spawn(|| Server::new(stream, handler).unwrap().handle_client()); thread::spawn(|| Handler::new(stream, handler).unwrap().handle_client());
} }
Err(_err) => { Err(_err) => {
/* connection failed */ /* connection failed */
+1 -1
View File
@@ -1,7 +1,7 @@
mod handler;
mod listener; mod listener;
pub mod options; pub mod options;
mod repository; mod repository;
mod server;
use crate::listener::Listener; use crate::listener::Listener;
use crate::options::OPTIONS; use crate::options::OPTIONS;