Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion client-sdks/reference/tauri.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ Connection locks and table updates are automatically shared between Rust and Jav

## Limitations

- The Rust SDK, which is used to implement the Tauri plugin, does not provide `lastSyncedAt`, `hasSynced` and `priorityStatusEntries` on `SyncStatus`. Use the status on individual Sync Streams through `SyncStatus.forStream` instead.
- Connecting to the PowerSync Service is only possible from Rust. Calling `connect()` from JavaScript will throw.

## Additional Usage Examples
Expand Down
69 changes: 65 additions & 4 deletions client-sdks/usage-examples.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,21 @@ import JavaScriptCallbackWatch from '/snippets/basic-watch-query-javascript-call
Also see [`ReadTransaction`](https://powersync-ja.github.io/powersync-dotnet/api/PowerSync.Common.Client.PowerSyncDatabase.ReadTransaction.html).
</Tab>
<Tab title="Rust">
Example not yet available.
```Rust
use powersync::{PowerSyncDatabase, error::PowerSyncError};
use rusqlite::params;

async fn delete_list(db: &PowerSyncDatabase, id: &str) -> Result<(), PowerSyncError> {
let mut writer = db.writer().await?;
let tx = writer.transaction()?;

tx.execute("DELETE FROM lists WHERE id = ?", params![id])?;
tx.execute("DELETE FROM todos WHERE list_id = ?", params![id])?;

tx.commit()?;
Ok(())
}
```
</Tab>
</Tabs>

Expand Down Expand Up @@ -949,7 +963,22 @@ import JavaScriptCallbackWatch from '/snippets/basic-watch-query-javascript-call
```
</Tab>
<Tab title="Rust">
Example not yet available.
```Rust
use futures_lite::StreamExt;
use powersync::PowerSyncDatabase;

async fn observe_status(db: &PowerSyncDatabase) {
let mut stream = db.watch_status();
// watch_status() also returns the current snapshot when first polled, but status() can be used
// if access to the status is needed synchronously.
let mut status = db.status();

loop {
println!("PowerSync status: {status:?}");
status = stream.next().await.unwrap();
}
}
```
</Tab>
</Tabs>

Expand Down Expand Up @@ -1128,7 +1157,17 @@ import JavaScriptCallbackWatch from '/snippets/basic-watch-query-javascript-call
```
</Tab>
<Tab title="Rust">
Example not yet available.
```Rust
use futures_lite::StreamExt;
use powersync::PowerSyncDatabase;

async fn wait_for_initial_sync(db: &PowerSyncDatabase) {
db.watch_status()
.filter(|status| status.has_synced())
.next()
.await;
}
```
</Tab>
</Tabs>

Expand Down Expand Up @@ -1465,6 +1504,28 @@ import JavaScriptCallbackWatch from '/snippets/basic-watch-query-javascript-call
- [Demo component](https://github.com/powersync-ja/powersync-dotnet/blob/main/demos/MAUITodo/Views/ListsPage.xaml.cs)
</Tab>
<Tab title="Rust">
Example not yet available.
The Rust SDK doesn't report global sync progress, but can report progress for a Sync Stream. For an auto-subscribe Sync Stream named `lists`, you can track progress with:

```Rust
use futures_lite::StreamExt;
use powersync::PowerSyncDatabase;

async fn print_progress(db: &PowerSyncDatabase) {
let stream = db.sync_stream("lists", None);
let mut status = db.watch_status();
while let Some(status) = status.next().await {
let progress = status
.for_stream(&stream)
.and_then(|stream| stream.progress);

if let Some(progress) = progress {
println!(
"Stream progress: {} out of {}",
progress.downloaded, progress.total
);
}
}
}
```
</Tab>
</Tabs>
Loading