[−][src]Struct scrappy_web_actors::ws::WebsocketContext
Execution context for WebSockets
actors
Methods
impl<A> WebsocketContext<A> where
A: Actor<Context = Self>,
[src]
A: Actor<Context = Self>,
pub fn create<S>(
actor: A,
stream: S
) -> impl Stream<Item = Result<Bytes, Error>> where
A: StreamHandler<Result<Message, ProtocolError>>,
S: Stream<Item = Result<Bytes, PayloadError>> + 'static,
[src]
actor: A,
stream: S
) -> impl Stream<Item = Result<Bytes, Error>> where
A: StreamHandler<Result<Message, ProtocolError>>,
S: Stream<Item = Result<Bytes, PayloadError>> + 'static,
Create a new Websocket context from a request and an actor
pub fn create_with_addr<S>(
actor: A,
stream: S
) -> (Addr<A>, impl Stream<Item = Result<Bytes, Error>>) where
A: StreamHandler<Result<Message, ProtocolError>>,
S: Stream<Item = Result<Bytes, PayloadError>> + 'static,
[src]
actor: A,
stream: S
) -> (Addr<A>, impl Stream<Item = Result<Bytes, Error>>) where
A: StreamHandler<Result<Message, ProtocolError>>,
S: Stream<Item = Result<Bytes, PayloadError>> + 'static,
Create a new Websocket context from a request and an actor.
Returns a pair, where the first item is an addr for the created actor,
and the second item is a stream intended to be set as part of the
response via HttpResponseBuilder::streaming()
.
pub fn with_codec<S>(
actor: A,
stream: S,
codec: Codec
) -> impl Stream<Item = Result<Bytes, Error>> where
A: StreamHandler<Result<Message, ProtocolError>>,
S: Stream<Item = Result<Bytes, PayloadError>> + 'static,
[src]
actor: A,
stream: S,
codec: Codec
) -> impl Stream<Item = Result<Bytes, Error>> where
A: StreamHandler<Result<Message, ProtocolError>>,
S: Stream<Item = Result<Bytes, PayloadError>> + 'static,
Create a new Websocket context from a request, an actor, and a codec
pub fn with_factory<S, F>(
stream: S,
f: F
) -> impl Stream<Item = Result<Bytes, Error>> where
F: FnOnce(&mut Self) -> A + 'static,
A: StreamHandler<Result<Message, ProtocolError>>,
S: Stream<Item = Result<Bytes, PayloadError>> + 'static,
[src]
stream: S,
f: F
) -> impl Stream<Item = Result<Bytes, Error>> where
F: FnOnce(&mut Self) -> A + 'static,
A: StreamHandler<Result<Message, ProtocolError>>,
S: Stream<Item = Result<Bytes, PayloadError>> + 'static,
Create a new Websocket context
impl<A> WebsocketContext<A> where
A: Actor<Context = Self>,
[src]
A: Actor<Context = Self>,
pub fn write_raw(&mut self, msg: Message)
[src]
Write payload
This is a low-level function that accepts framed messages that should
be created using Frame::message()
. If you want to send text or binary
data you should prefer the text()
or binary()
convenience functions
that handle the framing for you.
pub fn text<T: Into<String>>(&mut self, text: T)
[src]
Send text frame
pub fn binary<B: Into<Bytes>>(&mut self, data: B)
[src]
Send binary frame
pub fn ping(&mut self, message: &[u8])
[src]
Send ping frame
pub fn pong(&mut self, message: &[u8])
[src]
Send pong frame
pub fn close(&mut self, reason: Option<CloseReason>)
[src]
Send close frame
pub fn handle(&self) -> SpawnHandle
[src]
Handle of the running future
SpawnHandle is the handle returned by AsyncContext::spawn()
method.
pub fn set_mailbox_capacity(&mut self, cap: usize)
[src]
Set mailbox capacity
By default mailbox capacity is 16 messages.
Trait Implementations
impl<A> ActorContext for WebsocketContext<A> where
A: Actor<Context = Self>,
[src]
A: Actor<Context = Self>,
impl<A> AsyncContext<A> for WebsocketContext<A> where
A: Actor<Context = Self>,
[src]
A: Actor<Context = Self>,
fn spawn<F>(&mut self, fut: F) -> SpawnHandle where
F: ActorFuture<Output = (), Actor = A> + 'static,
[src]
F: ActorFuture<Output = (), Actor = A> + 'static,
fn wait<F>(&mut self, fut: F) where
F: ActorFuture<Output = (), Actor = A> + 'static,
[src]
F: ActorFuture<Output = (), Actor = A> + 'static,
fn cancel_future(&mut self, handle: SpawnHandle) -> bool
[src]
fn address(&self) -> Addr<A>
[src]
fn waiting(&self) -> bool
[src]
fn add_stream<S>(&mut self, fut: S) -> SpawnHandle where
A: StreamHandler<<S as Stream>::Item>,
S: Stream + 'static,
[src]
A: StreamHandler<<S as Stream>::Item>,
S: Stream + 'static,
fn add_message_stream<S>(&mut self, fut: S) where
A: Handler<<S as Stream>::Item>,
S: Stream + 'static,
<S as Stream>::Item: Message,
[src]
A: Handler<<S as Stream>::Item>,
S: Stream + 'static,
<S as Stream>::Item: Message,
fn notify<M>(&mut self, msg: M) where
A: Handler<M>,
M: Message + 'static,
[src]
A: Handler<M>,
M: Message + 'static,
fn notify_later<M>(&mut self, msg: M, after: Duration) -> SpawnHandle where
A: Handler<M>,
M: Message + 'static,
[src]
A: Handler<M>,
M: Message + 'static,
fn run_later<F>(&mut self, dur: Duration, f: F) -> SpawnHandle where
F: FnOnce(&mut A, &mut <A as Actor>::Context) + 'static,
[src]
F: FnOnce(&mut A, &mut <A as Actor>::Context) + 'static,
fn run_interval<F>(&mut self, dur: Duration, f: F) -> SpawnHandle where
F: FnMut(&mut A, &mut <A as Actor>::Context) + 'static,
[src]
F: FnMut(&mut A, &mut <A as Actor>::Context) + 'static,
impl<A> AsyncContextParts<A> for WebsocketContext<A> where
A: Actor<Context = Self>,
[src]
A: Actor<Context = Self>,
fn parts(&mut self) -> &mut ContextParts<A>
[src]
impl<A, M> ToEnvelope<A, M> for WebsocketContext<A> where
A: Actor<Context = WebsocketContext<A>> + Handler<M>,
M: scrappyMessage + Send + 'static,
M::Result: Send,
[src]
A: Actor<Context = WebsocketContext<A>> + Handler<M>,
M: scrappyMessage + Send + 'static,
M::Result: Send,
Auto Trait Implementations
impl<A> !RefUnwindSafe for WebsocketContext<A>
impl<A> !Send for WebsocketContext<A>
impl<A> !Sync for WebsocketContext<A>
impl<A> Unpin for WebsocketContext<A>
impl<A> !UnwindSafe for WebsocketContext<A>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,