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