pub struct SseEvent {
pub data: String,
pub event: Option<String>,
pub id: Option<String>,
pub retry: Option<u64>,
}Expand description
A Server-Sent Event
SSE events follow the format specified in the W3C Server-Sent Events specification. Each event can have:
data: The event data (required)event: The event type/name (optional)id: The event ID for reconnection (optional)retry: Reconnection time in milliseconds (optional)
Fields§
§data: StringThe event data
event: Option<String>The event type/name
id: Option<String>The event ID
retry: Option<u64>Reconnection time in milliseconds
Implementations§
Source§impl SseEvent
impl SseEvent
Sourcepub fn to_sse_string(&self) -> String
pub fn to_sse_string(&self) -> String
Format the event as an SSE message
The format follows the SSE specification:
- Lines starting with “event:” specify the event type
- Lines starting with “id:” specify the event ID
- Lines starting with “retry:” specify the reconnection time
- Lines starting with “data:” contain the event data
- Events are terminated with a blank line
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SseEvent
impl RefUnwindSafe for SseEvent
impl Send for SseEvent
impl Sync for SseEvent
impl Unpin 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