basic get / set / delete / has
This commit is contained in:
25
src/handler.rs
Normal file
25
src/handler.rs
Normal file
@@ -0,0 +1,25 @@
|
||||
use crate::{Result, connection::Connection, database::Database};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Handler {
|
||||
db: Database,
|
||||
connection: Connection,
|
||||
}
|
||||
|
||||
impl Handler {
|
||||
pub fn new(db: Database, connection: Connection) -> Self {
|
||||
Self { db, connection }
|
||||
}
|
||||
|
||||
pub async fn run(&mut self) -> Result<()> {
|
||||
while let Ok(command) = self.connection.read_command().await {
|
||||
let Some(command) = command else {
|
||||
break;
|
||||
};
|
||||
|
||||
command.execute(&self.db, &mut self.connection).await?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user