diff --git a/inc/liblektor-rs/database.h b/inc/liblektor-rs/database.h index 34b6ffd59d34f5016b4b520268ea0d7d79e4ae42..0660be6472abe46c045a8c13ae2b97ed87502fd0 100644 --- a/inc/liblektor-rs/database.h +++ b/inc/liblektor-rs/database.h @@ -7,6 +7,7 @@ extern "C" { #include <stdint.h> +struct lkt_uri; struct lkt_sqlite_connection; typedef struct lkt_sqlite_connection lkt_sqlite_connection; @@ -27,6 +28,15 @@ bool lkt_database_delete_kara_by_local_id(lkt_sqlite_connection *, int64_t); bool lkt_database_get_kara_info(lkt_sqlite_connection *, int64_t, lkt_info_cb, void *restrict); bool lkt_database_get_kara_tags(lkt_sqlite_connection *, int64_t, lkt_info_cb, void *restrict); +bool lkt_database_add_to_history(lkt_sqlite_connection *, int64_t); +bool lkt_database_iter_history(lkt_sqlite_connection *, void (*)(int64_t, void *restrict), + void *restrict); +bool lkt_database_clear_history(lkt_sqlite_connection *); +bool lkt_database_search(lkt_sqlite_connection *, lkt_uri *, void (*)(int64_t, void *restrict), + void *restrict); +bool lkt_database_search_playlist(lkt_sqlite_connection *, const char *, lkt_uri *, + void (*)(int64_t, void *restrict), void *restrict); + #if defined(__cplusplus) } #endif diff --git a/src/rust/lektor_db/src/connexion.rs b/src/rust/lektor_db/src/connexion.rs index 943540e9b00986b4c36c2c314e7d19f937fda0ed..a291037e4b33048d67a0dbc72aedf83b43f14b8a 100644 --- a/src/rust/lektor_db/src/connexion.rs +++ b/src/rust/lektor_db/src/connexion.rs @@ -234,11 +234,6 @@ impl LktDatabaseConnection { todo!() } - /// Search the queue by URIs. We return the local ids. - pub fn search_queue(&mut self, _uri: LktCUri) -> LktDatabaseResult<Vec<i64>> { - todo!() - } - /// Search the given playlist by URIs. We return the local ids. pub fn search_playlist<S: AsRef<str>>( &mut self, diff --git a/src/rust/lektor_unsafe/src/db.rs b/src/rust/lektor_unsafe/src/db.rs index 7ad17c31a04db81b26cba305c40e2a2b5ed2961d..1482e3f16317d78db99a9733f1c92e9170308471 100644 --- a/src/rust/lektor_unsafe/src/db.rs +++ b/src/rust/lektor_unsafe/src/db.rs @@ -120,3 +120,69 @@ pub unsafe extern "C" fn lkt_database_get_kara_tags( ) -> bool { unimplemented!() } + +/// Add the kara to the history. +/// ### Safety +/// The passed db pointer must be created by +/// [`lkt_database_establish_connection`]. +#[no_mangle] +pub unsafe extern "C" fn lkt_database_add_to_history( + db: *mut LktDatabaseConnection, + local_id: i64, +) -> bool { + todo!() +} + +/// Iterate over the history. +/// ### Safety +/// The passed db pointer must be created by +/// [`lkt_database_establish_connection`]. +#[no_mangle] +pub unsafe extern "C" fn lkt_database_iter_history( + db: *mut LktDatabaseConnection, + cb: extern "C" fn(i64, usize, *mut c_void), + user: *mut c_void, +) -> bool { + todo!() +} + +/// Clear the history. +/// ### Safety +/// The passed db pointer must be created by +/// [`lkt_database_establish_connection`]. +#[no_mangle] +pub unsafe extern "C" fn lkt_database_clear_history(db: *mut LktDatabaseConnection) -> bool { + todo!() +} + +/// Search the database. +/// ### Safety +/// The passed db pointer must be created by +/// [`lkt_database_establish_connection`]. The passed uri pointer must be a +/// valid an address to a URI. +#[no_mangle] +pub unsafe extern "C" fn lkt_database_search( + db: *mut LktDatabaseConnection, + uri: LktUriPtr, + cb: extern "C" fn(i64, *mut c_void), + user: *mut c_void, +) -> bool { + todo!() +} + +/// Search the specified playlist in database. +/// ### Safety +/// The passed db pointer must be created by +/// [`lkt_database_establish_connection`]. The passed uri pointer must be a +/// valid an address to a URI. The passed playlist name must be a valid C +/// string (a null terminated string). +#[no_mangle] +pub unsafe extern "C" fn lkt_database_search_playlist( + db: *mut LktDatabaseConnection, + playlist: *mut c_char, + uri: LktUriPtr, + cb: extern "C" fn(i64, *mut c_void), + user: *mut c_void, +) -> bool { + todo!() +}