Skip to content

Commit d7d705d

Browse files
committed
Prepare for crates.io publishing
1 parent 88e2172 commit d7d705d

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
lines changed

crates/core/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ repository.workspace = true
77
license.workspace = true
88
authors.workspace = true
99
keywords.workspace = true
10+
description = "The PowerSync SQLite extension"
11+
readme = "README.md"
1012

1113
[lib]
1214
name = "powersync_core"

crates/core/README.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
1+
<p align="center">
2+
<a href="https://www.powersync.com" target="_blank"><img src="https://github.com/powersync-ja/.github/assets/7372448/d2538c43-c1a0-4c47-9a76-41462dba484f"/></a>
3+
</p>
4+
5+
_[PowerSync](https://www.powersync.com) is a sync engine for building local-first apps with instantly-responsive UI/UX and simplified state transfer. Syncs between SQLite on the client-side and Postgres, MongoDB or MySQL on the server-side._
6+
17
# powersync_core
28

3-
This is the core SQLite extension, containing all the logic.
9+
This is the core SQLite extension, containing all the logic. This is used internally by PowerSync SDKs,
10+
and would typically not be used by users directly.
11+
12+
The role of the extension is to create user-defined functions that higher-level SDKs would use to implement
13+
schema management and a PowerSync client.
14+
Not all of this is documented, but [this directory](https://github.com/powersync-ja/powersync-sqlite-core/tree/main/docs)
15+
provides some hints on how a custom PowerSync SDK could be implemented.
416

5-
Since the different build configurations (loadable extension, bundled SQLite shell)
6-
use different cargo config, we can't completely separate them just using features.
7-
Instead, we use different crates depending on this core lib.
17+
For this reason, the crate doesn't have much of a public API. In the default build mode, it doesn't expect
18+
SQLite to be linked and exposes a single function: `sqlite3_powersync_init`,
19+
a [loadable extension](https://sqlite.org/loadext.html) entrypoint.
820

21+
For applications linking SQLite, the `static` feature of this crate can be enabled.
22+
With that feature, `powersync_init_static()` can be called to load the
23+
extension for all new connections.
24+
The application is responsible for linking SQLite in that case.

crates/core/src/lib.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ mod view_admin;
3535
mod views;
3636
mod vtab_util;
3737

38+
/// The entrypoint for the PowerSync SQLite core extension.
39+
///
40+
/// When compiling this Rust crate into a dynamic library, it can be used by embedders to load it
41+
/// through [SQLite's opening mechanism](https://sqlite.org/loadext.html#loading_an_extension).
3842
#[unsafe(no_mangle)]
3943
pub extern "C" fn sqlite3_powersync_init(
4044
db: *mut sqlite::sqlite3,
@@ -85,7 +89,7 @@ fn init_extension(db: *mut sqlite::sqlite3) -> Result<(), PowerSyncError> {
8589
unsafe extern "C" {
8690
#[cfg(feature = "static")]
8791
#[allow(non_snake_case)]
88-
pub fn sqlite3_auto_extension(
92+
fn sqlite3_auto_extension(
8993
xEntryPoint: Option<
9094
extern "C" fn(
9195
*mut sqlite::sqlite3,
@@ -96,6 +100,10 @@ unsafe extern "C" {
96100
) -> ::core::ffi::c_int;
97101
}
98102

103+
/// Calls `sqlite3_auto_extension` with [sqlite3_powersync_init] to automatically load
104+
/// the PowerSync core extension into new connections.
105+
///
106+
/// For details, see https://sqlite.org/loadext.html#statically_linking_a_run_time_loadable_extension
99107
#[cfg(feature = "static")]
100108
#[unsafe(no_mangle)]
101109
pub extern "C" fn powersync_init_static() -> c_int {

crates/sqlite_nostd/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ repository.workspace = true
77
license.workspace = true
88
authors.workspace = true
99
keywords.workspace = true
10+
description = "Lightweight, semi-unsafe, nostd bindings to sqlite3"
11+
readme = "README.md"
1012

1113
[lib]
1214
name = "powersync_sqlite_nostd"

0 commit comments

Comments
 (0)