Skip to main content

RelaySession

Struct RelaySession 

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

One deterministic transport-independent relay session.

Implementations§

Source§

impl RelaySession

Source

pub const fn new() -> Self

Create one disconnected session with empty bounded queues.

Source

pub fn connect(&mut self) -> Result<RelaySessionAction, SoftchatError>

Begin a platform-owned connection attempt.

§Errors

Returns SoftchatError::InvalidRelaySession unless disconnected or waiting in backoff.

Source

pub fn transport_connected(&mut self) -> Result<(), SoftchatError>

Notify the session that the native WebSocket is open.

Existing subscriptions are replayed only after the host indicates authentication is complete.

§Errors

Returns a stable transition error from any state except Connecting.

Source

pub fn authenticated(&mut self) -> Result<(), SoftchatError>

Mark NIP-42 authentication complete and replay session intent.

§Errors

Returns a transition or bounded-queue failure.

Source

pub fn subscribe( &mut self, subscription_id: String, filters: Vec<RelayFilter>, ) -> Result<(), SoftchatError>

Add or replace one subscription intent.

The request is queued immediately when ready and retained across reconnects.

§Errors

Returns a validation, state, or bounded-queue failure.

Source

pub fn close_subscription( &mut self, subscription_id: &str, ) -> Result<(), SoftchatError>

Close one retained subscription.

§Errors

Returns a state or bounded-queue failure.

Source

pub fn publish( &mut self, events: Vec<SignedNostrEvent>, ) -> Result<(), SoftchatError>

Queue one or more already persisted authored events for publication.

§Errors

Returns a state, duplicate-ID, event-validation, or queue failure.

Source

pub fn receive( &mut self, frame_json: &str, ) -> Result<Vec<RelaySessionAction>, SoftchatError>

Consume one complete relay WebSocket text frame.

§Errors

Returns a frame, state, correlation, or backpressure failure.

Source

pub fn confirm_ingested(&mut self, event_id: &str) -> Result<(), SoftchatError>

Confirm that an authoritative platform transaction handled an event.

§Errors

Returns a stable state error for an unknown or repeated confirmation.

Source

pub fn transport_lost( &mut self, ) -> Result<Vec<RelaySessionAction>, SoftchatError>

Handle transport loss and classify only nonterminal in-flight events for retry.

§Errors

Returns a transition error when no live transport existed.

Source

pub fn cancel(&mut self) -> RelaySessionAction

Permanently cancel and clear process-local queues.

Source

pub fn drain_outbound( &mut self, limit: usize, ) -> Result<Vec<String>, SoftchatError>

Drain at most limit queued frames for the platform WebSocket.

§Errors

Returns a stable state error for zero limits.

Source

pub fn snapshot(&self) -> RelaySessionSnapshot

Return a stable non-secret snapshot.

Trait Implementations§

Source§

impl Debug for RelaySession

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RelaySession

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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.

§

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

§

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

Create a new handle for an Arc value Read more
§

unsafe fn clone_handle(handle: Handle) -> Handle

Clone a handle Read more
§

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

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

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.
§

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

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,