pub struct SseMessage {
pub event: Option<String>,
pub data: String,
pub last_event_id: Option<String>,
}Expand description
One EventSource-style message dispatch after data: line reassembly.
Fields§
§event: Option<String>event: field if present; callers may treat None as the default message type.
data: StringConcatenated data: payload.
last_event_id: Option<String>Last event id after applying this frame and any prior control-only id: frames.
Implementations§
Source§impl SseMessage
impl SseMessage
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 message’s data payload as JSON.
§Type parameters
T: Target type deserialized fromSseMessage::data.
§Returns
Ok(T) when data is valid JSON for T.
§Errors
Returns HttpError::sse_decode when JSON parsing fails.
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 message’s data payload as JSON with configurable strictness.
§Parameters
mode: JSON decoding strictness.
§Type parameters
T: Target type deserialized fromSseMessage::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§
Source§impl Clone for SseMessage
impl Clone for SseMessage
Source§fn clone(&self) -> SseMessage
fn clone(&self) -> SseMessage
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SseMessage
impl Debug for SseMessage
Source§impl PartialEq for SseMessage
impl PartialEq for SseMessage
Source§fn eq(&self, other: &SseMessage) -> bool
fn eq(&self, other: &SseMessage) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Eq for SseMessage
impl StructuralPartialEq for SseMessage
Auto Trait Implementations§
impl Freeze for SseMessage
impl RefUnwindSafe for SseMessage
impl Send for SseMessage
impl Sync for SseMessage
impl Unpin for SseMessage
impl UnsafeUnpin for SseMessage
impl UnwindSafe for SseMessage
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.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, D> IntoConfigDefault<T> for Dwhere
D: IntoValueDefault<T>,
impl<T, D> IntoConfigDefault<T> for Dwhere
D: IntoValueDefault<T>,
Source§fn into_config_default(self) -> T
fn into_config_default(self) -> T
Converts this fallback value into
T.Source§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
type Err = Infallible
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>
Source§impl<T> IntoValueDefault<T> for T
impl<T> IntoValueDefault<T> for T
Source§fn into_value_default(self) -> T
fn into_value_default(self) -> T
Converts this argument into the default value.