pub struct SseEvent { /* private fields */ }Expand description
A single Server-Sent Event.
Build with SseEvent::data and chain the optional setter methods.
Use Sse::push to add it to a response.
Implementations§
Source§impl SseEvent
impl SseEvent
Sourcepub fn data(data: impl Into<String>) -> Self
pub fn data(data: impl Into<String>) -> Self
Create an event with the given data payload. Multi-line strings produce
multiple data: lines, which the client concatenates with \n.
Sourcepub fn id(self, id: impl Into<String>) -> Self
pub fn id(self, id: impl Into<String>) -> Self
Set the id field. Clients use this to resume from the last event
seen after a reconnection (Last-Event-ID request header).
Sourcepub fn event_type(self, event: impl Into<String>) -> Self
pub fn event_type(self, event: impl Into<String>) -> Self
Set the event type (event field). Clients listen for specific types
with addEventListener("type", handler). Defaults to "message".
Auto Trait Implementations§
impl Freeze for SseEvent
impl RefUnwindSafe for SseEvent
impl Send for SseEvent
impl Sync for SseEvent
impl Unpin for SseEvent
impl UnsafeUnpin for SseEvent
impl UnwindSafe for SseEvent
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