Skip to content

Commit f4a71e1

Browse files
committed
Move wp_api/cache to new wp_mobile_cache crate
1 parent 9cb1d3b commit f4a71e1

File tree

14 files changed

+56
-12
lines changed

14 files changed

+56
-12
lines changed

Cargo.lock

Lines changed: 11 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ members = [
1313
"wp_localization_parser",
1414
"wp_localization_validation",
1515
"wp_mobile",
16+
"wp_mobile_cache",
1617
"wp_rs_cli",
1718
"wp_rs_web",
1819
"wp_serde_helper",

native/kotlin/api/kotlin/src/main/kotlin/rs/wordpress/cache/kotlin/WordPressApiCache.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ package rs.wordpress.cache.kotlin
22

33
import kotlinx.coroutines.asCoroutineDispatcher
44
import kotlinx.coroutines.withContext
5-
import uniffi.wp_api.DatabaseDelegate
6-
import uniffi.wp_api.UpdateHook
7-
import uniffi.wp_api.WpApiCache
5+
import uniffi.wp_mobile_cache.DatabaseDelegate
6+
import uniffi.wp_mobile_cache.UpdateHook
7+
import uniffi.wp_mobile_cache.WpApiCache
88
import java.nio.file.Path
99
import java.util.concurrent.Executors
1010

@@ -13,6 +13,7 @@ class WordPressApiCacheLoggingDelegate : DatabaseDelegate {
1313
println("Received update: $updateHook")
1414
}
1515
}
16+
1617
class WordPressApiCacheDelegate(
1718
private val callback: (updateHook: UpdateHook) -> Unit
1819
) : DatabaseDelegate {
@@ -31,7 +32,10 @@ class WordPressApiCache {
3132
constructor(delegate: WordPressApiCacheDelegate? = null) : this(":memory:", delegate)
3233

3334
// Creates a new cache at the specified file system URL
34-
constructor(path: Path, delegate: WordPressApiCacheDelegate? = null) : this(path.toString(), delegate)
35+
constructor(path: Path, delegate: WordPressApiCacheDelegate? = null) : this(
36+
path.toString(),
37+
delegate
38+
)
3539

3640
// Creates a new cache at the specified path
3741
constructor(string: String, delegate: WordPressApiCacheDelegate? = null) {
@@ -42,6 +46,7 @@ class WordPressApiCache {
4246
suspend fun performMigrations(): Int = withContext(internalDispatcher) {
4347
cache.performMigrations().toInt()
4448
}
49+
4550
fun startListeningForUpdates() {
4651
if (this.delegate != null) {
4752
this.cache.startListeningForUpdates(this.delegate)

native/kotlin/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ allprojects {
3333
exclude("**/wp_api.kt")
3434
exclude("**/wp_localization.kt")
3535
exclude("**/wp_mobile.kt")
36+
exclude("**/wp_mobile_cache.kt")
3637
}
3738

3839
tasks.withType<io.gitlab.arturbosch.detekt.DetektCreateBaselineTask>().configureEach {
@@ -42,6 +43,7 @@ allprojects {
4243
exclude("**/wp_api.kt")
4344
exclude("**/wp_localization.kt")
4445
exclude("**/wp_mobile.kt")
46+
exclude("**/wp_mobile_cache.kt")
4547
}
4648

4749
dependencies {

wp_api/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ version = "0.1.0"
44
edition = "2024"
55

66
[features]
7-
default = ["rusqlite/bundled"]
87
export-uncancellable-endpoints = ["wp_derive_request_builder/export-uncancellable-endpoints"]
98
integration-tests = []
109
reqwest-request-executor = ["dep:reqwest", "dep:tokio", "dep:hyper-util", "dep:rustls", "dep:hickory-resolver", "dep:hyper", "dep:h2"]
@@ -49,7 +48,6 @@ wp_localization = { path = "../wp_localization" }
4948
wp_localization_macro = { path = "../wp_localization_macro" }
5049
wp_serde_helper = { path = "../wp_serde_helper" }
5150
x509-cert = { workspace = true }
52-
rusqlite = { version = "0.37.0", features = ["hooks"] }
5351

5452
[dev-dependencies]
5553
rstest = { workspace = true }

wp_api/src/cache/mod.rs

Lines changed: 0 additions & 1 deletion
This file was deleted.

wp_api/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use users::*;
66
use wp_localization::{MessageBundle, WpMessages, WpSupportsLocalization};
77
use wp_localization_macro::WpDeriveLocalizable;
88

9-
pub mod cache;
109
pub mod jetpack;
1110
pub mod wp_com;
1211

wp_mobile/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ name = "wp_mobile"
1313
[dependencies]
1414
uniffi = { workspace = true }
1515
wp_api = { path = "../wp_api" }
16+
wp_mobile_cache = { path = "../wp_mobile_cache" }
1617

1718
[build-dependencies]
1819
uniffi = { workspace = true , features = [ "build", "cli" ] }

wp_mobile/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
// Re-export wp_api to ensure its bindings are generated
1+
// Re-export to ensure its bindings are generated
22
pub use wp_api;
3+
pub use wp_mobile_cache;
34

45
#[uniffi::export]
56
fn wp_mobile_crate_works(input: String) -> String {

wp_mobile_cache/Cargo.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "wp_mobile_cache"
3+
version = "0.1.0"
4+
edition = "2024"
5+
6+
[features]
7+
default = ["rusqlite/bundled"]
8+
9+
[dependencies]
10+
rusqlite = { version = "0.37.0", features = ["hooks"] }
11+
thiserror = { workspace = true }
12+
uniffi = { workspace = true }
13+
wp_api = { path = "../wp_api" }

0 commit comments

Comments
 (0)