pub struct RealtimeSession { /* private fields */ }Expand description
A live realtime WebSocket session.
Wraps the underlying WebSocket stream and exposes JSON send/receive.
Implementations§
Source§impl RealtimeSession
impl RealtimeSession
Sourcepub async fn send(&mut self, event: Value) -> Result<(), RealtimeError>
pub async fn send(&mut self, event: Value) -> Result<(), RealtimeError>
Send a JSON event as a text frame.
Not cancel-safe: dropping this future mid-flight (e.g. racing it in
tokio::select!) can leave a partial frame on the connection. Let it
run to completion.
Sourcepub async fn recv(&mut self) -> Result<Option<Value>, RealtimeError>
pub async fn recv(&mut self) -> Result<Option<Value>, RealtimeError>
Receive the next JSON event.
Returns Ok(None) on a clean close. Ping/Pong frames are handled
automatically by the underlying library and skipped here; non-text
frames other than binary JSON are skipped as well. This method is
cancel-safe. Keep polling it even when idle — server pings are only
answered while a read is in progress, and an unpolled session may be
dropped by the server.
Sourcepub async fn close(self) -> Result<(), RealtimeError>
pub async fn close(self) -> Result<(), RealtimeError>
Close the connection with a normal closure handshake.
Auto Trait Implementations§
impl !Freeze for RealtimeSession
impl !RefUnwindSafe for RealtimeSession
impl !UnwindSafe for RealtimeSession
impl Send for RealtimeSession
impl Sync for RealtimeSession
impl Unpin for RealtimeSession
impl UnsafeUnpin for RealtimeSession
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