diff options
| author | Teddy Wing | 2021-05-29 19:20:46 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2021-05-29 19:20:46 +0200 | 
| commit | 9c2d269945af68e67d8daf8870be6d5664ab2153 (patch) | |
| tree | 342eb952ac43ac7b28d97224160b8bb1ed71e5fd /src | |
| parent | c90d237d2d39c1deac5f92344d13160bc16f50b7 (diff) | |
| download | reflectub-9c2d269945af68e67d8daf8870be6d5664ab2153.tar.bz2 | |
Start setting up database interface
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();  } | 
