From 9c2d269945af68e67d8daf8870be6d5664ab2153 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 29 May 2021 19:20:46 +0200 Subject: Start setting up database interface --- src/database.rs | 37 +++++++++++++++++++++++++++++++++++++ src/lib.rs | 1 + src/main.rs | 15 ++++++++++----- 3 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 src/database.rs (limited to 'src') 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> { + Ok( + Db { + connection: sqlx::SqliteConnection::connect(path) + .await?, + } + ) + } + + pub fn create() -> Result<(), Box> { + Ok(()) + } + + pub fn repo_insert(repo: &Repo) -> Result<(), Box> { + Ok(()) + } + + pub fn repo_is_updated() -> Result> { + Ok(false) + } + + pub fn repo_update(repo: &Repo) -> Result<(), Box> { + Ok(()) + } +} diff --git a/src/lib.rs b/src/lib.rs index 02a52f7..bc1e023 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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(); } -- cgit v1.2.3