pub struct PjsWebSocketClient { /* private fields */ }Expand description
WebSocket client for receiving PJS streams
Implementations§
Source§impl PjsWebSocketClient
impl PjsWebSocketClient
Sourcepub fn with_write_timeout(self, write_timeout: Duration) -> Self
pub fn with_write_timeout(self, write_timeout: Duration) -> Self
Overrides the deadline for a single outbound WebSocket sink write,
used by the send_task spawned in Self::connect.
Defaults to infrastructure::websocket::WRITE_TIMEOUT (10s) — see
its doc for the rationale and the tradeoff it implies for large
frames sent to slow clients. Pair a shorter value with a
resource-constrained deployment where freeing a wedged send task
quickly matters more than absorbing network jitter (mirroring
RateLimitConfig::low_resource’s tightened write_timeout on the
server side); pair a longer value with a deployment that expects
large payloads over slow or high-latency uplinks and would
otherwise see legitimate writes misclassified as stalled.
write_timeout is not validated: Duration::ZERO leaves at most
one poll of the underlying write before it is treated as a timeout,
and an arbitrarily large value (including Duration::MAX) is
accepted as-is and does not panic, since tokio::time::timeout
clamps internally.
§Examples
use pjson_rs::infrastructure::websocket::PjsWebSocketClient;
use std::time::Duration;
let client = PjsWebSocketClient::new("ws://localhost:3001/ws")
.unwrap()
.with_write_timeout(Duration::from_secs(3));Sourcepub async fn connect(&self) -> PjsResult<()>
pub async fn connect(&self) -> PjsResult<()>
Connect to WebSocket server and start message handling
Sourcepub async fn request_stream(
&self,
data: Value,
options: Option<StreamOptions>,
) -> PjsResult<String>
pub async fn request_stream( &self, data: Value, options: Option<StreamOptions>, ) -> PjsResult<String>
Request stream initialization
Sourcepub async fn get_current_data(
&self,
session_id: &str,
) -> PjsResult<Option<Value>>
pub async fn get_current_data( &self, session_id: &str, ) -> PjsResult<Option<Value>>
Get current reconstructed data for session
Sourcepub async fn is_stream_complete(&self, session_id: &str) -> bool
pub async fn is_stream_complete(&self, session_id: &str) -> bool
Check if stream is complete
Sourcepub async fn get_stream_stats(&self, session_id: &str) -> Option<StreamStats>
pub async fn get_stream_stats(&self, session_id: &str) -> Option<StreamStats>
Get stream statistics
Auto Trait Implementations§
impl !RefUnwindSafe for PjsWebSocketClient
impl !UnwindSafe for PjsWebSocketClient
impl Freeze for PjsWebSocketClient
impl Send for PjsWebSocketClient
impl Sync for PjsWebSocketClient
impl Unpin for PjsWebSocketClient
impl UnsafeUnpin for PjsWebSocketClient
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more