pub struct SseArgs<'a> {
pub id: Option<&'a str>,
pub event: &'a str,
pub data: &'a str,
}Expand description
Represents an update in a Server-Sent Events (SSE) stream.
See Response::on_sse for more details.
Fields§
§id: Option<&'a str>Id.
event: &'a strEvent name.
Empty means message.
data: &'a strData.
Implementations§
Source§impl<'a> SseArgs<'a>
impl<'a> SseArgs<'a>
Sourcepub fn is_message(&self) -> bool
pub fn is_message(&self) -> bool
Gets if is not a custom event.
Handling data only when this is true is the equivalent of
subscribing to EventSource.onmessage in Javascript.
Sourcepub fn json<O: Deserialize<'a>>(&self) -> Result<O, Error>
pub fn json<O: Deserialize<'a>>(&self) -> Result<O, Error>
Try to deserialize data from JSON.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for SseArgs<'a>
impl<'a> RefUnwindSafe for SseArgs<'a>
impl<'a> Send for SseArgs<'a>
impl<'a> Sync for SseArgs<'a>
impl<'a> Unpin for SseArgs<'a>
impl<'a> UnsafeUnpin for SseArgs<'a>
impl<'a> UnwindSafe for SseArgs<'a>
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more