rename 'handler' to 'repository' for clarity
This commit is contained in:
@@ -7,19 +7,19 @@ pub const RESPONSE_OK: [u8; 4] = [0x0, 0x2, b'O', b'K'];
|
||||
|
||||
pub struct Handler<S: Read + Write> {
|
||||
stream: S,
|
||||
handler: PasswordDirectory,
|
||||
repository: PasswordDirectory,
|
||||
}
|
||||
|
||||
impl<S: Read + Write> Handler<S> {
|
||||
pub fn new(stream: S, handler: PasswordDirectory) -> Handler<S> {
|
||||
Handler { stream, handler }
|
||||
pub fn new(stream: S, repository: PasswordDirectory) -> Handler<S> {
|
||||
Handler { stream, repository }
|
||||
}
|
||||
|
||||
fn communicate(&mut self) -> Result<(), Error> {
|
||||
let request = Request::from_stream(&mut self.stream)?;
|
||||
|
||||
println!("userid: {}", request.userid);
|
||||
if self.handler.check_auth(&request) {
|
||||
if self.repository.check_auth(&request) {
|
||||
self.stream.write_all(&RESPONSE_OK)?
|
||||
} else {
|
||||
self.stream.write_all(&RESPONSE_NO)?
|
||||
|
||||
Reference in New Issue
Block a user