diff options
author | 2025-03-01 09:12:32 +0000 | |
---|---|---|
committer | 2025-03-01 09:12:32 +0000 | |
commit | 542a8e299c7bfe85419d52120bdc3d7a92dcfe38 (patch) | |
tree | 34151ebe5ecc90c9c5468f63c62b4fc69479759f /luz/src/main.rs | |
parent | 357311cb930f15be5d743143584883475cb42e5d (diff) | |
download | luz-542a8e299c7bfe85419d52120bdc3d7a92dcfe38.tar.gz luz-542a8e299c7bfe85419d52120bdc3d7a92dcfe38.tar.bz2 luz-542a8e299c7bfe85419d52120bdc3d7a92dcfe38.zip |
refactor(luz): create Db separate from LuzHandle
Diffstat (limited to 'luz/src/main.rs')
-rw-r--r-- | luz/src/main.rs | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/luz/src/main.rs b/luz/src/main.rs index 2506883..4b74b39 100644 --- a/luz/src/main.rs +++ b/luz/src/main.rs @@ -1,7 +1,7 @@ -use std::{str::FromStr, time::Duration}; +use std::{path::Path, str::FromStr, time::Duration}; use jid::JID; -use luz::{CommandMessage, LuzHandle}; +use luz::{db::Db, CommandMessage, LuzHandle}; use sqlx::SqlitePool; use tokio::{ io::{AsyncReadExt, AsyncWriteExt}, @@ -12,13 +12,11 @@ use tracing::info; #[tokio::main] async fn main() { tracing_subscriber::fmt::init(); - let (luz, mut recv) = LuzHandle::new( - "test@blos.sm".try_into().unwrap(), - "slayed".to_string(), - "./luz.db", - ) - .await - .unwrap(); + let db = Db::create_connect_and_migrate(Path::new("./luz.db")) + .await + .unwrap(); + let (luz, mut recv) = + LuzHandle::new("test@blos.sm".try_into().unwrap(), "slayed".to_string(), db).unwrap(); tokio::spawn(async move { while let Some(msg) = recv.recv().await { |