Skip to main content

tauri_plugin_nostr_sync/
lib.rs

1use tauri::{plugin::TauriPlugin, Manager, Runtime};
2
3pub use models::*;
4
5#[cfg(desktop)]
6mod desktop;
7#[cfg(mobile)]
8mod mobile;
9
10mod builder;
11mod commands;
12mod error;
13mod models;
14mod state;
15
16pub use builder::PluginBuilder;
17/// Alias for `PluginBuilder` matching the spec's `tauri_plugin_nostr_sync::Builder::new()` usage.
18pub use builder::PluginBuilder as Builder;
19pub use error::{Error, Result};
20pub use state::{NostrSyncState, DEFAULT_PAYLOAD_LIMIT, MAX_PAYLOAD_LIMIT};
21
22#[cfg(desktop)]
23use desktop::TauriPluginNostrSync;
24#[cfg(mobile)]
25use mobile::TauriPluginNostrSync;
26
27pub trait TauriPluginNostrSyncExt<R: Runtime> {
28    fn nostr_sync(&self) -> &TauriPluginNostrSync<R>;
29}
30
31impl<R: Runtime, T: Manager<R>> TauriPluginNostrSyncExt<R> for T {
32    fn nostr_sync(&self) -> &TauriPluginNostrSync<R> {
33        self.state::<TauriPluginNostrSync<R>>().inner()
34    }
35}
36
37pub fn init<R: Runtime>() -> TauriPlugin<R> {
38    PluginBuilder::new().build()
39}