pub struct SessionManagerHandle { /* private fields */ }Expand description
FFI wrapper for SessionManager.
Implementations§
Source§impl SessionManagerHandle
impl SessionManagerHandle
Sourcepub fn new(
our_pubkey_hex: String,
our_identity_privkey_hex: String,
device_id: String,
owner_pubkey_hex: Option<String>,
) -> Result<Arc<Self>, NdrError>
pub fn new( our_pubkey_hex: String, our_identity_privkey_hex: String, device_id: String, owner_pubkey_hex: Option<String>, ) -> Result<Arc<Self>, NdrError>
Create a new session manager with an internal event queue.
Sourcepub fn new_with_storage_path(
our_pubkey_hex: String,
our_identity_privkey_hex: String,
device_id: String,
storage_path: String,
owner_pubkey_hex: Option<String>,
) -> Result<Arc<Self>, NdrError>
pub fn new_with_storage_path( our_pubkey_hex: String, our_identity_privkey_hex: String, device_id: String, storage_path: String, owner_pubkey_hex: Option<String>, ) -> Result<Arc<Self>, NdrError>
Create a new session manager with file-backed storage.
Sourcepub fn init(&self) -> Result<(), NdrError>
pub fn init(&self) -> Result<(), NdrError>
Initialize the session manager (loads state, creates device invite, subscribes).
Sourcepub fn setup_user(&self, user_pubkey_hex: String) -> Result<(), NdrError>
pub fn setup_user(&self, user_pubkey_hex: String) -> Result<(), NdrError>
Subscribe to a user’s AppKeys/device-invite streams and converge sessions.
Sourcepub fn accept_invite_from_url(
&self,
invite_url: String,
owner_pubkey_hint_hex: Option<String>,
) -> Result<SessionManagerAcceptInviteResult, NdrError>
pub fn accept_invite_from_url( &self, invite_url: String, owner_pubkey_hint_hex: Option<String>, ) -> Result<SessionManagerAcceptInviteResult, NdrError>
Accept an invite URL using SessionManager’s owner-aware routing/auth checks.
This flow also emits the signed invite response via SessionManager pubsub events,
so hosts should continue draining and publishing publish_signed events.
Sourcepub fn accept_invite_from_event_json(
&self,
event_json: String,
owner_pubkey_hint_hex: Option<String>,
) -> Result<SessionManagerAcceptInviteResult, NdrError>
pub fn accept_invite_from_event_json( &self, event_json: String, owner_pubkey_hint_hex: Option<String>, ) -> Result<SessionManagerAcceptInviteResult, NdrError>
Accept an invite event JSON using SessionManager’s owner-aware routing/auth checks.
Sourcepub fn send_text(
&self,
recipient_pubkey_hex: String,
text: String,
expires_at_seconds: Option<u64>,
) -> Result<Vec<String>, NdrError>
pub fn send_text( &self, recipient_pubkey_hex: String, text: String, expires_at_seconds: Option<u64>, ) -> Result<Vec<String>, NdrError>
Send a text message to a recipient.
Sourcepub fn send_text_with_inner_id(
&self,
recipient_pubkey_hex: String,
text: String,
expires_at_seconds: Option<u64>,
) -> Result<SendTextResult, NdrError>
pub fn send_text_with_inner_id( &self, recipient_pubkey_hex: String, text: String, expires_at_seconds: Option<u64>, ) -> Result<SendTextResult, NdrError>
Send a text message and return both the stable inner (rumor) id and the list of outer message event ids that were published.
Sourcepub fn send_event_with_inner_id(
&self,
recipient_pubkey_hex: String,
kind: u32,
content: String,
tags_json: String,
created_at_seconds: Option<u64>,
) -> Result<SendTextResult, NdrError>
pub fn send_event_with_inner_id( &self, recipient_pubkey_hex: String, kind: u32, content: String, tags_json: String, created_at_seconds: Option<u64>, ) -> Result<SendTextResult, NdrError>
Send an arbitrary inner rumor event to a recipient, returning stable inner id + outer ids.
This is used for group chats where we need custom kinds/tags (e.g. group metadata kind 40, group-tagged chat messages kind 14, reactions kind 7, typing kind 25).
The caller controls the inner rumor tags via tags_json (JSON array of string arrays).
For group fan-out, do NOT include recipient-specific tags like ["p", <recipient>] so
the inner rumor id stays stable across all recipients.
Sourcepub fn send_rumor_json(
&self,
recipient_pubkey_hex: String,
rumor_json: String,
) -> Result<SendTextResult, NdrError>
pub fn send_rumor_json( &self, recipient_pubkey_hex: String, rumor_json: String, ) -> Result<SendTextResult, NdrError>
Send an already-built rumor JSON to a recipient without rebuilding it.
This preserves the original rumor pubkey, timestamp, tags, and id.
Sourcepub fn group_upsert(&self, group: FfiGroupData) -> Result<(), NdrError>
pub fn group_upsert(&self, group: FfiGroupData) -> Result<(), NdrError>
Upsert group metadata into the embedded GroupManager.
Sourcepub fn group_create(
&self,
name: String,
member_owner_pubkeys: Vec<String>,
fanout_metadata: Option<bool>,
now_ms: Option<u64>,
) -> Result<GroupCreateResult, NdrError>
pub fn group_create( &self, name: String, member_owner_pubkeys: Vec<String>, fanout_metadata: Option<bool>, now_ms: Option<u64>, ) -> Result<GroupCreateResult, NdrError>
Create a group through the embedded GroupManager, with optional metadata fanout.
Sourcepub fn group_remove(&self, group_id: String)
pub fn group_remove(&self, group_id: String)
Remove a group from the embedded GroupManager.
Sourcepub fn group_known_sender_event_pubkeys(&self) -> Vec<String>
pub fn group_known_sender_event_pubkeys(&self) -> Vec<String>
Return known sender-event pubkeys used for one-to-many group transport.
Sourcepub fn group_outer_subscription_plan(&self) -> GroupOuterSubscriptionPlanResult
pub fn group_outer_subscription_plan(&self) -> GroupOuterSubscriptionPlanResult
Return the current group outer authors and which ones were newly added since the last sync plan request for this handle.
Sourcepub fn group_send_event(
&self,
group_id: String,
kind: u32,
content: String,
tags_json: String,
now_ms: Option<u64>,
) -> Result<GroupSendResult, NdrError>
pub fn group_send_event( &self, group_id: String, kind: u32, content: String, tags_json: String, now_ms: Option<u64>, ) -> Result<GroupSendResult, NdrError>
Send a group event through GroupManager.
Pairwise sender-key distribution rumors are sent through SessionManager sessions. The encrypted one-to-many outer event is emitted via the SessionManager pubsub queue.
Sourcepub fn group_handle_incoming_session_event(
&self,
event_json: String,
from_owner_pubkey_hex: String,
from_sender_device_pubkey_hex: Option<String>,
) -> Result<Vec<GroupDecryptedResult>, NdrError>
pub fn group_handle_incoming_session_event( &self, event_json: String, from_owner_pubkey_hex: String, from_sender_device_pubkey_hex: Option<String>, ) -> Result<Vec<GroupDecryptedResult>, NdrError>
Handle a decrypted pairwise session rumor that may carry sender-key distribution.
Sourcepub fn group_handle_outer_event(
&self,
event_json: String,
) -> Result<Option<GroupDecryptedResult>, NdrError>
pub fn group_handle_outer_event( &self, event_json: String, ) -> Result<Option<GroupDecryptedResult>, NdrError>
Handle an incoming relay event that may be an encrypted one-to-many group outer event.
Sourcepub fn send_receipt(
&self,
recipient_pubkey_hex: String,
receipt_type: String,
message_ids: Vec<String>,
expires_at_seconds: Option<u64>,
) -> Result<Vec<String>, NdrError>
pub fn send_receipt( &self, recipient_pubkey_hex: String, receipt_type: String, message_ids: Vec<String>, expires_at_seconds: Option<u64>, ) -> Result<Vec<String>, NdrError>
Send a delivery/read receipt for messages.
Sourcepub fn send_typing(
&self,
recipient_pubkey_hex: String,
expires_at_seconds: Option<u64>,
) -> Result<Vec<String>, NdrError>
pub fn send_typing( &self, recipient_pubkey_hex: String, expires_at_seconds: Option<u64>, ) -> Result<Vec<String>, NdrError>
Send a typing indicator.
Sourcepub fn send_reaction(
&self,
recipient_pubkey_hex: String,
message_id: String,
emoji: String,
expires_at_seconds: Option<u64>,
) -> Result<Vec<String>, NdrError>
pub fn send_reaction( &self, recipient_pubkey_hex: String, message_id: String, emoji: String, expires_at_seconds: Option<u64>, ) -> Result<Vec<String>, NdrError>
Send an emoji reaction (kind 7) to a specific message id.
Sourcepub fn import_session_state(
&self,
peer_pubkey_hex: String,
state_json: String,
device_id: Option<String>,
) -> Result<(), NdrError>
pub fn import_session_state( &self, peer_pubkey_hex: String, state_json: String, device_id: Option<String>, ) -> Result<(), NdrError>
Import a session state for a peer.
Sourcepub fn get_active_session_state(
&self,
peer_pubkey_hex: String,
) -> Result<Option<String>, NdrError>
pub fn get_active_session_state( &self, peer_pubkey_hex: String, ) -> Result<Option<String>, NdrError>
Export the active session state for a peer.
Sourcepub fn known_peer_owner_pubkeys(&self) -> Vec<String>
pub fn known_peer_owner_pubkeys(&self) -> Vec<String>
List peer owner pubkeys known from loaded state or persisted storage.
Sourcepub fn get_stored_user_record_json(
&self,
peer_owner_pubkey_hex: String,
) -> Result<Option<String>, NdrError>
pub fn get_stored_user_record_json( &self, peer_owner_pubkey_hex: String, ) -> Result<Option<String>, NdrError>
Return the persisted user-record snapshot JSON for a peer owner, if present.
Return the tracked message-push author pubkeys for a peer owner.
Sourcepub fn get_message_push_session_states(
&self,
peer_owner_pubkey_hex: String,
) -> Result<Vec<MessagePushSessionStateResult>, NdrError>
pub fn get_message_push_session_states( &self, peer_owner_pubkey_hex: String, ) -> Result<Vec<MessagePushSessionStateResult>, NdrError>
Return pairwise session snapshots used for message-push routing for a peer owner.
Sourcepub fn process_event(&self, event_json: String) -> Result<(), NdrError>
pub fn process_event(&self, event_json: String) -> Result<(), NdrError>
Process a received Nostr event JSON.
Sourcepub fn drain_events(&self) -> Result<Vec<PubSubEvent>, NdrError>
pub fn drain_events(&self) -> Result<Vec<PubSubEvent>, NdrError>
Drain pending pubsub events from the internal queue.
Sourcepub fn get_device_id(&self) -> String
pub fn get_device_id(&self) -> String
Get our device id.
Sourcepub fn get_our_pubkey_hex(&self) -> String
pub fn get_our_pubkey_hex(&self) -> String
Get our public key as hex.
Sourcepub fn get_owner_pubkey_hex(&self) -> String
pub fn get_owner_pubkey_hex(&self) -> String
Get owner public key as hex.
Sourcepub fn get_total_sessions(&self) -> u64
pub fn get_total_sessions(&self) -> u64
Get total active sessions.