pub struct SseEvent {
pub event: Option<String>,
pub data: Option<Bytes>,
pub id: Option<String>,
pub retry: Option<u64>,
}Expand description
Represents a single Server-Sent Event (SSE) as defined in the SSE protocol.
Contains the event type, data payload, and optional event ID.
Fields§
§event: Option<String>The optional event type (e.g., “message”).
data: Option<Bytes>The optional data payload of the event, stored as bytes.
id: Option<String>The optional event ID for reconnection or tracking purposes.
retry: Option<u64>Optional reconnection retry interval (in milliseconds).
Implementations§
Source§impl SseEvent
impl SseEvent
Sourcepub fn with_event<T>(self, event: T) -> SseEvent
pub fn with_event<T>(self, event: T) -> SseEvent
Sets the event name (e.g., “message”).
Sourcepub fn with_retry(self, retry: u64) -> SseEvent
pub fn with_retry(self, retry: u64) -> SseEvent
Sets the retry interval (in milliseconds).
Sourcepub fn with_data_bytes(self, data: Bytes) -> SseEvent
pub fn with_data_bytes(self, data: Bytes) -> SseEvent
Sets the data as bytes.
Sourcepub fn to_sse_string(&self) -> String
pub fn to_sse_string(&self) -> String
Converts the event into a string in SSE format (ready for HTTP body).
pub fn as_bytes(&self) -> Bytes
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.