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::os::unix::net::UnixStream;
pub struct Server {
pub struct Handler {
stream: UnixStream,
handler: PasswordDirectory,
}
impl Server {
pub fn new(stream: UnixStream, handler: PasswordDirectory) -> Result<Server, Error> {
Ok(Server { stream, handler })
impl Handler {
pub fn new(stream: UnixStream, handler: PasswordDirectory) -> Result<Handler, Error> {
Ok(Handler { stream, handler })
}
fn communicate(&mut self) -> Result<(), Error> {
+2 -2
View File
@@ -1,6 +1,6 @@
use crate::handler::Handler;
use crate::options::OPTIONS;
use crate::repository::PasswordDirectory;
use crate::server::Server;
use std::fs::{metadata, set_permissions};
use std::io::Error;
use std::os::unix::fs::PermissionsExt;
@@ -34,7 +34,7 @@ impl Listener {
Ok(stream) => {
/* connection succeeded */
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) => {
/* connection failed */
+1 -1
View File
@@ -1,7 +1,7 @@
mod handler;
mod listener;
pub mod options;
mod repository;
mod server;
use crate::listener::Listener;
use crate::options::OPTIONS;