mirror of
https://github.com/lifegpc/pixiv_downloader.git
synced 2026-07-08 01:32:41 +08:00
Update
This commit is contained in:
4
.github/workflows/CI.yml
vendored
4
.github/workflows/CI.yml
vendored
@@ -104,9 +104,9 @@ jobs:
|
||||
- name: Check Out
|
||||
uses: actions/checkout@v2
|
||||
- name: Build
|
||||
run: cargo build --features server -vv
|
||||
run: cargo build --features server,db_sqlite -vv
|
||||
- name: Run tests
|
||||
run: cargo test --features server --verbose -- --show-output
|
||||
run: cargo test --features server,db_sqlite --verbose -- --show-output
|
||||
build-all:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
@@ -47,6 +47,7 @@ cmake = { version = "0.1", optional = true }
|
||||
all = ["db", "db_sqlite", "exif", "ugoira", "server"]
|
||||
avdict = ["bindgen", "cmake", "flagset"]
|
||||
db = []
|
||||
db_all = ["db", "db_sqlite"]
|
||||
db_sqlite = ["rusqlite"]
|
||||
exif = ["bindgen", "c_fixed_string", "cmake", "link-cplusplus", "utf16string"]
|
||||
server = ["async-trait", "db", "hyper"]
|
||||
|
||||
7
src/db/config.rs
Normal file
7
src/db/config.rs
Normal file
@@ -0,0 +1,7 @@
|
||||
pub struct PixivDownloaderDbConfig {}
|
||||
|
||||
impl AsRef<PixivDownloaderDbConfig> for PixivDownloaderDbConfig {
|
||||
fn as_ref(&self) -> &PixivDownloaderDbConfig {
|
||||
self
|
||||
}
|
||||
}
|
||||
20
src/db/mod.rs
Normal file
20
src/db/mod.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
pub mod config;
|
||||
#[cfg(feature = "db_sqlite")]
|
||||
pub mod sqlite;
|
||||
pub mod traits;
|
||||
|
||||
pub use config::PixivDownloaderDbConfig;
|
||||
#[cfg(feature = "db_sqlite")]
|
||||
pub use sqlite::SqliteError;
|
||||
pub use traits::PixivDownloaderDb;
|
||||
pub type PixivDownloaderDbError = Box<dyn std::fmt::Display + Send + Sync>;
|
||||
|
||||
#[cfg(feature = "db_sqlite")]
|
||||
impl From<SqliteError> for PixivDownloaderDbError {
|
||||
fn from(e: SqliteError) -> Self {
|
||||
Box::new(e)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "db_sqlite"))]
|
||||
compile_error!("No database backend is enabled.");
|
||||
2
src/db/sqlite/error.rs
Normal file
2
src/db/sqlite/error.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
#[derive(derive_more::Display, derive_more::From)]
|
||||
pub enum SqliteError {}
|
||||
3
src/db/sqlite/mod.rs
Normal file
3
src/db/sqlite/mod.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
pub mod error;
|
||||
|
||||
pub use error::SqliteError;
|
||||
11
src/db/traits.rs
Normal file
11
src/db/traits.rs
Normal file
@@ -0,0 +1,11 @@
|
||||
use super::PixivDownloaderDbConfig;
|
||||
use super::PixivDownloaderDbError;
|
||||
|
||||
pub trait PixivDownloaderDb {
|
||||
/// Create a new instance of database
|
||||
fn new<R: AsRef<PixivDownloaderDbConfig> + ?Sized>(
|
||||
cfg: &R,
|
||||
) -> Result<Self, PixivDownloaderDbError>
|
||||
where
|
||||
Self: Sized;
|
||||
}
|
||||
@@ -19,6 +19,8 @@ mod _ugoira;
|
||||
mod avdict;
|
||||
mod cookies;
|
||||
mod data;
|
||||
#[cfg(feature = "db")]
|
||||
mod db;
|
||||
mod download;
|
||||
mod downloader;
|
||||
mod dur;
|
||||
|
||||
Reference in New Issue
Block a user