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 !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