pub struct SseEvent {
pub event: Option<String>,
pub data: String,
pub id: Option<String>,
pub retry: Option<u64>,
}Expand description
One Server-Sent Events dispatch after frame reassembly (data: lines joined with \n).
Fields§
§event: Option<String>event: field if present.
data: StringConcatenated data: payload (newline-separated if multiple data lines).
id: Option<String>id: field if present.
retry: Option<u64>Parsed retry: milliseconds hint if valid.
Implementations§
Source§impl SseEvent
impl SseEvent
Sourcepub fn decode_json<T>(&self) -> HttpResult<T>where
T: DeserializeOwned,
pub fn decode_json<T>(&self) -> HttpResult<T>where
T: DeserializeOwned,
Decodes the current event’s data payload as JSON.
§Type parameters
T: Target type deserialized fromSseEvent::data.
§Returns
Ok(T) when data is valid JSON for T.
§Errors
Returns HttpError::sse_decode when JSON parsing fails.
The error message includes optional event and id context.
Sourcepub fn decode_json_with_mode<T>(
&self,
mode: SseJsonMode,
) -> HttpResult<Option<T>>where
T: DeserializeOwned,
pub fn decode_json_with_mode<T>(
&self,
mode: SseJsonMode,
) -> HttpResult<Option<T>>where
T: DeserializeOwned,
Decodes the current event’s data payload as JSON with configurable strictness.
§Parameters
mode: JSON decoding strictness.
§Type parameters
T: Target type deserialized fromSseEvent::data.
§Returns
Ok(Some(T))whendatais valid JSON forT.Ok(None)in lenient mode when JSON parsing fails.
§Errors
Returns HttpError::sse_decode in strict mode when JSON parsing fails.
Trait Implementations§
impl Eq for SseEvent
impl StructuralPartialEq for SseEvent
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.