pub struct WebSocket<S, E, OnInit, OnPing> { /* private fields */ }
Expand description
Implementations§
Source§impl<S, E> WebSocket<S, E, DefaultOnConnInitType, DefaultOnPingType>
impl<S, E> WebSocket<S, E, DefaultOnConnInitType, DefaultOnPingType>
Sourcepub fn from_message_stream(executor: E, stream: S, protocol: Protocols) -> Self
pub fn from_message_stream(executor: E, stream: S, protocol: Protocols) -> Self
Create a new websocket from ClientMessage
stream.
Source§impl<S, E> WebSocket<Map<S, fn(<S as Stream>::Item) -> Result<ClientMessage>>, E, DefaultOnConnInitType, DefaultOnPingType>
impl<S, E> WebSocket<Map<S, fn(<S as Stream>::Item) -> Result<ClientMessage>>, E, DefaultOnConnInitType, DefaultOnPingType>
Source§impl<S, E, OnInit, OnPing> WebSocket<S, E, OnInit, OnPing>
impl<S, E, OnInit, OnPing> WebSocket<S, E, OnInit, OnPing>
Sourcepub fn connection_data(self, data: Data) -> Self
pub fn connection_data(self, data: Data) -> Self
Specify a connection data.
This data usually comes from HTTP requests.
When the GQL_CONNECTION_INIT
message is received, this data will be
merged with the data returned by the closure specified by
with_initializer
into the final subscription context data.
Sourcepub fn on_connection_init<F, R>(self, callback: F) -> WebSocket<S, E, F, OnPing>
pub fn on_connection_init<F, R>(self, callback: F) -> WebSocket<S, E, F, OnPing>
Specify a connection initialize callback function.
This function if present, will be called with the data sent by the
client in the GQL_CONNECTION_INIT
message.
From that point on the returned data will be accessible to all requests.
Sourcepub fn on_ping<F, R>(self, callback: F) -> WebSocket<S, E, OnInit, F>
pub fn on_ping<F, R>(self, callback: F) -> WebSocket<S, E, OnInit, F>
Specify a ping callback function.
This function if present, will be called with the data sent by the
client in the Ping
message.
The function should return the data to be sent in the Pong
message.
NOTE: Only used for the graphql-ws
protocol.
Sourcepub fn keepalive_timeout(self, timeout: impl Into<Option<Duration>>) -> Self
pub fn keepalive_timeout(self, timeout: impl Into<Option<Duration>>) -> Self
Sets a timeout for receiving an acknowledgement of the keep-alive ping.
If the ping is not acknowledged within the timeout, the connection will be closed.
NOTE: Only used for the graphql-ws
protocol.
Trait Implementations§
Source§impl<S, E, OnInit, InitFut, OnPing, PingFut> Stream for WebSocket<S, E, OnInit, OnPing>where
E: Executor,
S: Stream<Item = Result<ClientMessage>>,
OnInit: FnOnce(Value) -> InitFut + Send + 'static,
InitFut: Future<Output = Result<Data>> + Send + 'static,
OnPing: FnOnce(Option<&Data>, Option<Value>) -> PingFut + Clone + Send + 'static,
PingFut: Future<Output = Result<Option<Value>>> + Send + 'static,
impl<S, E, OnInit, InitFut, OnPing, PingFut> Stream for WebSocket<S, E, OnInit, OnPing>where
E: Executor,
S: Stream<Item = Result<ClientMessage>>,
OnInit: FnOnce(Value) -> InitFut + Send + 'static,
InitFut: Future<Output = Result<Data>> + Send + 'static,
OnPing: FnOnce(Option<&Data>, Option<Value>) -> PingFut + Clone + Send + 'static,
PingFut: Future<Output = Result<Option<Value>>> + Send + 'static,
impl<'__pin, S, E, OnInit, OnPing> Unpin for WebSocket<S, E, OnInit, OnPing>where
PinnedFieldsOf<__Origin<'__pin, S, E, OnInit, OnPing>>: Unpin,
Auto Trait Implementations§
impl<S, E, OnInit, OnPing> Freeze for WebSocket<S, E, OnInit, OnPing>
impl<S, E, OnInit, OnPing> !RefUnwindSafe for WebSocket<S, E, OnInit, OnPing>
impl<S, E, OnInit, OnPing> Send for WebSocket<S, E, OnInit, OnPing>
impl<S, E, OnInit, OnPing> !Sync for WebSocket<S, E, OnInit, OnPing>
impl<S, E, OnInit, OnPing> !UnwindSafe for WebSocket<S, E, OnInit, OnPing>
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
Source§impl<T> StreamExt for T
impl<T> StreamExt for T
Source§fn next(&mut self) -> Next<'_, Self> ⓘwhere
Self: Unpin,
fn next(&mut self) -> Next<'_, Self> ⓘwhere
Self: Unpin,
Source§fn into_future(self) -> StreamFuture<Self> ⓘ
fn into_future(self) -> StreamFuture<Self> ⓘ
Source§fn map<T, F>(self, f: F) -> Map<Self, F>
fn map<T, F>(self, f: F) -> Map<Self, F>
Source§fn enumerate(self) -> Enumerate<Self>where
Self: Sized,
fn enumerate(self) -> Enumerate<Self>where
Self: Sized,
Source§fn filter<Fut, F>(self, f: F) -> Filter<Self, Fut, F>
fn filter<Fut, F>(self, f: F) -> Filter<Self, Fut, F>
Source§fn filter_map<Fut, T, F>(self, f: F) -> FilterMap<Self, Fut, F>
fn filter_map<Fut, T, F>(self, f: F) -> FilterMap<Self, Fut, F>
Source§fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
Source§fn collect<C>(self) -> Collect<Self, C> ⓘ
fn collect<C>(self) -> Collect<Self, C> ⓘ
Source§fn unzip<A, B, FromA, FromB>(self) -> Unzip<Self, FromA, FromB> ⓘ
fn unzip<A, B, FromA, FromB>(self) -> Unzip<Self, FromA, FromB> ⓘ
Source§fn concat(self) -> Concat<Self> ⓘ
fn concat(self) -> Concat<Self> ⓘ
Source§fn count(self) -> Count<Self> ⓘwhere
Self: Sized,
fn count(self) -> Count<Self> ⓘwhere
Self: Sized,
Source§fn fold<T, Fut, F>(self, init: T, f: F) -> Fold<Self, Fut, T, F> ⓘ
fn fold<T, Fut, F>(self, init: T, f: F) -> Fold<Self, Fut, T, F> ⓘ
Source§fn any<Fut, F>(self, f: F) -> Any<Self, Fut, F> ⓘ
fn any<Fut, F>(self, f: F) -> Any<Self, Fut, F> ⓘ
true
if any element in stream satisfied a predicate. Read moreSource§fn all<Fut, F>(self, f: F) -> All<Self, Fut, F> ⓘ
fn all<Fut, F>(self, f: F) -> All<Self, Fut, F> ⓘ
true
if all element in stream satisfied a predicate. Read moreSource§fn flatten(self) -> Flatten<Self>
fn flatten(self) -> Flatten<Self>
Source§fn flatten_unordered(
self,
limit: impl Into<Option<usize>>,
) -> FlattenUnorderedWithFlowController<Self, ()>
fn flatten_unordered( self, limit: impl Into<Option<usize>>, ) -> FlattenUnorderedWithFlowController<Self, ()>
Source§fn flat_map_unordered<U, F>(
self,
limit: impl Into<Option<usize>>,
f: F,
) -> FlatMapUnordered<Self, U, F>
fn flat_map_unordered<U, F>( self, limit: impl Into<Option<usize>>, f: F, ) -> FlatMapUnordered<Self, U, F>
StreamExt::map
but flattens nested Stream
s
and polls them concurrently, yielding items in any order, as they made
available. Read moreSource§fn scan<S, B, Fut, F>(self, initial_state: S, f: F) -> Scan<Self, S, Fut, F>
fn scan<S, B, Fut, F>(self, initial_state: S, f: F) -> Scan<Self, S, Fut, F>
StreamExt::fold
that holds internal state
and produces a new stream. Read moreSource§fn skip_while<Fut, F>(self, f: F) -> SkipWhile<Self, Fut, F>
fn skip_while<Fut, F>(self, f: F) -> SkipWhile<Self, Fut, F>
true
. Read moreSource§fn take_while<Fut, F>(self, f: F) -> TakeWhile<Self, Fut, F>
fn take_while<Fut, F>(self, f: F) -> TakeWhile<Self, Fut, F>
true
. Read moreSource§fn take_until<Fut>(self, fut: Fut) -> TakeUntil<Self, Fut>
fn take_until<Fut>(self, fut: Fut) -> TakeUntil<Self, Fut>
Source§fn for_each<Fut, F>(self, f: F) -> ForEach<Self, Fut, F> ⓘ
fn for_each<Fut, F>(self, f: F) -> ForEach<Self, Fut, F> ⓘ
Source§fn for_each_concurrent<Fut, F>(
self,
limit: impl Into<Option<usize>>,
f: F,
) -> ForEachConcurrent<Self, Fut, F> ⓘ
fn for_each_concurrent<Fut, F>( self, limit: impl Into<Option<usize>>, f: F, ) -> ForEachConcurrent<Self, Fut, F> ⓘ
Source§fn take(self, n: usize) -> Take<Self>where
Self: Sized,
fn take(self, n: usize) -> Take<Self>where
Self: Sized,
n
items of the underlying stream. Read moreSource§fn skip(self, n: usize) -> Skip<Self>where
Self: Sized,
fn skip(self, n: usize) -> Skip<Self>where
Self: Sized,
n
items of the underlying stream. Read moreSource§fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
Source§fn boxed<'a>(self) -> Pin<Box<dyn Stream<Item = Self::Item> + Send + 'a>>
fn boxed<'a>(self) -> Pin<Box<dyn Stream<Item = Self::Item> + Send + 'a>>
Source§fn boxed_local<'a>(self) -> Pin<Box<dyn Stream<Item = Self::Item> + 'a>>where
Self: Sized + 'a,
fn boxed_local<'a>(self) -> Pin<Box<dyn Stream<Item = Self::Item> + 'a>>where
Self: Sized + 'a,
Source§fn buffered(self, n: usize) -> Buffered<Self>
fn buffered(self, n: usize) -> Buffered<Self>
Source§fn buffer_unordered(self, n: usize) -> BufferUnordered<Self>
fn buffer_unordered(self, n: usize) -> BufferUnordered<Self>
Source§fn zip<St>(self, other: St) -> Zip<Self, St>
fn zip<St>(self, other: St) -> Zip<Self, St>
Source§fn peekable(self) -> Peekable<Self>where
Self: Sized,
fn peekable(self) -> Peekable<Self>where
Self: Sized,
peek
method. Read moreSource§fn chunks(self, capacity: usize) -> Chunks<Self>where
Self: Sized,
fn chunks(self, capacity: usize) -> Chunks<Self>where
Self: Sized,
Source§fn ready_chunks(self, capacity: usize) -> ReadyChunks<Self>where
Self: Sized,
fn ready_chunks(self, capacity: usize) -> ReadyChunks<Self>where
Self: Sized,
Source§fn forward<S>(self, sink: S) -> Forward<Self, S> ⓘ
fn forward<S>(self, sink: S) -> Forward<Self, S> ⓘ
Source§fn split<Item>(self) -> (SplitSink<Self, Item>, SplitStream<Self>)
fn split<Item>(self) -> (SplitSink<Self, Item>, SplitStream<Self>)
Source§fn inspect<F>(self, f: F) -> Inspect<Self, F>
fn inspect<F>(self, f: F) -> Inspect<Self, F>
Source§fn left_stream<B>(self) -> Either<Self, B> ⓘ
fn left_stream<B>(self) -> Either<Self, B> ⓘ
Source§fn right_stream<B>(self) -> Either<B, Self> ⓘ
fn right_stream<B>(self) -> Either<B, Self> ⓘ
Source§fn poll_next_unpin(&mut self, cx: &mut Context<'_>) -> Poll<Option<Self::Item>>where
Self: Unpin,
fn poll_next_unpin(&mut self, cx: &mut Context<'_>) -> Poll<Option<Self::Item>>where
Self: Unpin,
Stream::poll_next
on Unpin
stream types.