Files
archive/src/handler.rs
2025-06-12 15:52:01 +02:00

26 lines
577 B
Rust

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(())
}
}