pub struct RelaySession { /* private fields */ }Expand description
One deterministic transport-independent relay session.
Implementations§
Source§impl RelaySession
impl RelaySession
Sourcepub fn connect(&mut self) -> Result<RelaySessionAction, SoftchatError>
pub fn connect(&mut self) -> Result<RelaySessionAction, SoftchatError>
Begin a platform-owned connection attempt.
§Errors
Returns SoftchatError::InvalidRelaySession unless disconnected or
waiting in backoff.
Sourcepub fn transport_connected(&mut self) -> Result<(), SoftchatError>
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.
Sourcepub fn authenticated(&mut self) -> Result<(), SoftchatError>
pub fn authenticated(&mut self) -> Result<(), SoftchatError>
Mark NIP-42 authentication complete and replay session intent.
§Errors
Returns a transition or bounded-queue failure.
Sourcepub fn subscribe(
&mut self,
subscription_id: String,
filters: Vec<RelayFilter>,
) -> Result<(), SoftchatError>
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.
Sourcepub fn close_subscription(
&mut self,
subscription_id: &str,
) -> Result<(), SoftchatError>
pub fn close_subscription( &mut self, subscription_id: &str, ) -> Result<(), SoftchatError>
Sourcepub fn publish(
&mut self,
events: Vec<SignedNostrEvent>,
) -> Result<(), SoftchatError>
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.
Sourcepub fn receive(
&mut self,
frame_json: &str,
) -> Result<Vec<RelaySessionAction>, SoftchatError>
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.
Sourcepub fn confirm_ingested(&mut self, event_id: &str) -> Result<(), SoftchatError>
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.
Sourcepub fn transport_lost(
&mut self,
) -> Result<Vec<RelaySessionAction>, SoftchatError>
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.
Sourcepub fn cancel(&mut self) -> RelaySessionAction
pub fn cancel(&mut self) -> RelaySessionAction
Permanently cancel and clear process-local queues.
Sourcepub fn drain_outbound(
&mut self,
limit: usize,
) -> Result<Vec<String>, SoftchatError>
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.
Sourcepub fn snapshot(&self) -> RelaySessionSnapshot
pub fn snapshot(&self) -> RelaySessionSnapshot
Return a stable non-secret snapshot.
Trait Implementations§
Source§impl Debug for RelaySession
impl Debug for RelaySession
Auto Trait Implementations§
impl Freeze for RelaySession
impl RefUnwindSafe for RelaySession
impl Send for RelaySession
impl Sync for RelaySession
impl Unpin for RelaySession
impl UnsafeUnpin for RelaySession
impl UnwindSafe for RelaySession
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
§unsafe fn consume_handle(handle: Handle) -> Arc<T>
unsafe fn consume_handle(handle: Handle) -> Arc<T>
Arc<> Read more