Skip to main content

SessionManagerHandle

Struct SessionManagerHandle 

Source
pub struct SessionManagerHandle { /* private fields */ }
Expand description

FFI wrapper for SessionManager.

Implementations§

Source§

impl SessionManagerHandle

Source

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.

Source

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.

Source

pub fn init(&self) -> Result<(), NdrError>

Initialize the session manager (loads state, creates device invite, subscribes).

Source

pub fn setup_user(&self, user_pubkey_hex: String) -> Result<(), NdrError>

Subscribe to a user’s AppKeys/device-invite streams and converge sessions.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn group_upsert(&self, group: FfiGroupData) -> Result<(), NdrError>

Upsert group metadata into the embedded GroupManager.

Source

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.

Source

pub fn group_remove(&self, group_id: String)

Remove a group from the embedded GroupManager.

Source

pub fn group_known_sender_event_pubkeys(&self) -> Vec<String>

Return known sender-event pubkeys used for one-to-many group transport.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn send_typing( &self, recipient_pubkey_hex: String, expires_at_seconds: Option<u64>, ) -> Result<Vec<String>, NdrError>

Send a typing indicator.

Source

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.

Source

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.

Source

pub fn get_active_session_state( &self, peer_pubkey_hex: String, ) -> Result<Option<String>, NdrError>

Export the active session state for a peer.

Source

pub fn known_peer_owner_pubkeys(&self) -> Vec<String>

List peer owner pubkeys known from loaded state or persisted storage.

Source

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.

Source

pub fn get_message_push_author_pubkeys( &self, peer_owner_pubkey_hex: String, ) -> Result<Vec<String>, NdrError>

Return the tracked message-push author pubkeys for a peer owner.

Source

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.

Source

pub fn process_event(&self, event_json: String) -> Result<(), NdrError>

Process a received Nostr event JSON.

Source

pub fn drain_events(&self) -> Result<Vec<PubSubEvent>, NdrError>

Drain pending pubsub events from the internal queue.

Source

pub fn get_device_id(&self) -> String

Get our device id.

Source

pub fn get_our_pubkey_hex(&self) -> String

Get our public key as hex.

Source

pub fn get_owner_pubkey_hex(&self) -> String

Get owner public key as hex.

Source

pub fn get_total_sessions(&self) -> u64

Get total active sessions.

Trait Implementations§

Source§

impl<UT> LiftRef<UT> for SessionManagerHandle

Source§

impl<UT> LowerError<UT> for SessionManagerHandle

Source§

fn lower_error(obj: Self) -> RustBuffer

Lower this value for scaffolding function return Read more
Source§

impl<UT> LowerReturn<UT> for SessionManagerHandle

Source§

type ReturnType = <Arc<SessionManagerHandle> as LowerReturn<UniFfiTag>>::ReturnType

The type that should be returned by scaffolding functions for this type. Read more
Source§

fn lower_return(obj: Self) -> Result<Self::ReturnType, RustCallError>

Lower the return value from an scaffolding call Read more
Source§

fn handle_failed_lift( error: LiftArgsError, ) -> Result<Self::ReturnType, RustCallError>

Lower the return value for failed argument lifts Read more
Source§

impl<UT> TypeId<UT> for SessionManagerHandle

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, UT> HandleAlloc<UT> for T
where T: Send + Sync,

Source§

fn new_handle(value: Arc<T>) -> Handle

Create a new handle for an Arc value Read more
Source§

unsafe fn clone_handle(handle: Handle) -> Handle

Clone a handle Read more
Source§

unsafe fn consume_handle(handle: Handle) -> Arc<T>

Consume a handle, getting back the initial Arc<> Read more
Source§

unsafe fn get_arc(handle: Handle) -> Arc<Self>

Get a clone of the Arc<> using a “borrowed” handle. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V