pub struct RelayConnection { /* private fields */ }Expand description
Handle to a relay WebSocket connection running in its own thread.
Each connection runs in a dedicated OS thread with non-blocking I/O. The thread can be signaled to shut down via an atomic flag.
Implementations§
Source§impl RelayConnection
impl RelayConnection
Sourcepub fn spawn(
relay_url: String,
producer: Producer<PoolMessage>,
outbound: Consumer<String>,
shutdown: Arc<AtomicBool>,
) -> Self
pub fn spawn( relay_url: String, producer: Producer<PoolMessage>, outbound: Consumer<String>, shutdown: Arc<AtomicBool>, ) -> Self
Spawn a new thread that connects to a relay with bidirectional messaging.
The thread reads inbound events into the MPSC ring buffer and sends outbound messages from the broadcast consumer to the WebSocket.
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Returns true if the connection thread has exited.
Sourcepub fn request_shutdown(&self)
pub fn request_shutdown(&self)
Signal the connection thread to shut down gracefully.
The thread will send a WebSocket Close frame and exit within one poll cycle (~1ms). Does not block.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RelayConnection
impl !RefUnwindSafe for RelayConnection
impl Send for RelayConnection
impl Sync for RelayConnection
impl Unpin for RelayConnection
impl !UnwindSafe for RelayConnection
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
Mutably borrows from an owned value. Read more