Struct actix_web_lab::sse::Sender
source · pub struct Sender { /* private fields */ }
Expand description
Sender half of a server-sent events stream.
Implementations§
source§impl Sender
impl Sender
sourcepub async fn send(&self, msg: impl Into<Event>) -> Result<(), SendError>
pub async fn send(&self, msg: impl Into<Event>) -> Result<(), SendError>
Send an SSE message.
§Errors
Errors if the receiving (Sse
) has been dropped, likely because the client disconnected.
§Examples
#[actix_web::main] async fn test() {
use actix_web_lab::sse;
let (sender, sse_stream) = sse::channel(5);
sender.send(sse::Data::new("my data").event("my event name")).await.unwrap();
sender.send(sse::Event::Comment("my comment".into())).await.unwrap();
sourcepub fn try_send(&self, msg: impl Into<Event>) -> Result<(), TrySendError>
pub fn try_send(&self, msg: impl Into<Event>) -> Result<(), TrySendError>
Tries to send SSE message.
§Errors
Errors if:
- the the SSE buffer is currently full;
- the receiving (
Sse
) has been dropped, likely because the client disconnected.
§Examples
#[actix_web::main] async fn test() {
use actix_web_lab::sse;
let (sender, sse_stream) = sse::channel(5);
sender.try_send(sse::Data::new("my data").event("my event name")).unwrap();
sender.try_send(sse::Event::Comment("my comment".into())).unwrap();
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Sender
impl RefUnwindSafe for Sender
impl Send for Sender
impl Sync for Sender
impl Unpin for Sender
impl UnwindSafe for Sender
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)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>
Converts
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>
Converts
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