diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/database.rs | 37 | ||||
-rw-r--r-- | src/lib.rs | 1 | ||||
-rw-r--r-- | src/main.rs | 15 |
3 files changed, 48 insertions, 5 deletions
diff --git a/src/database.rs b/src/database.rs new file mode 100644 index 0000000..1b00377 --- /dev/null +++ b/src/database.rs @@ -0,0 +1,37 @@ +use sqlx::{self, Connection}; + +use crate::github::Repo; + + +pub struct Db { + connection: sqlx::SqliteConnection, +} + +impl Db { + pub async fn connect( + path: &str, + ) -> Result<Self, Box<dyn std::error::Error>> { + Ok( + Db { + connection: sqlx::SqliteConnection::connect(path) + .await?, + } + ) + } + + pub fn create() -> Result<(), Box<dyn std::error::Error>> { + Ok(()) + } + + pub fn repo_insert(repo: &Repo) -> Result<(), Box<dyn std::error::Error>> { + Ok(()) + } + + pub fn repo_is_updated() -> Result<bool, Box<dyn std::error::Error>> { + Ok(false) + } + + pub fn repo_update(repo: &Repo) -> Result<(), Box<dyn std::error::Error>> { + Ok(()) + } +} @@ -1,2 +1,3 @@ +pub mod database; pub mod git; pub mod github; diff --git a/src/main.rs b/src/main.rs index 70489bb..e27694d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,12 @@ -use reflectub::{git, github}; +use tokio; + +use reflectub::{database, git, github}; use std::path::Path; -fn main() { +#[tokio::main] +async fn main() { // let repos = github::fetch_repos().unwrap(); // // dbg!(&repos); @@ -13,7 +16,9 @@ fn main() { // Path::new("/tmp/grsvp"), // ).unwrap(); - git::update( - Path::new("/tmp/grsvp"), - ).unwrap(); + // git::update( + // Path::new("/tmp/grsvp"), + // ).unwrap(); + + let db = database::Db::connect("sqlite::memory:").await.unwrap(); } |