[−][src]Struct hyper_usse::Event
A server sent event.
The fields id
, event
and data
set the id
, event
and data
parameters for the event
respectively. id
and event
are optional. To convert it to an SSE string, use the to_sse
function.
Examples
let event = hyper_usse::Event::new("some text\nmore text").set_id("1").set_event("send_text"); assert_eq!(event.to_sse(), "id: 1 event: send_text data: some text data: more text\n\n");
Fields
id: Option<Cow<'static, str>>
event: Option<Cow<'static, str>>
data: Cow<'static, str>
Methods
impl Event
[src]
pub fn new<T: Into<Cow<'static, str>>>(data: T) -> Self
[src]
Creates a new Event from data.
pub fn set_id<T: Into<Cow<'static, str>>>(self, id: T) -> Self
[src]
Sets the id of the event. As it returns self
, it is useful for creating an event inline.
pub fn set_event<T: Into<Cow<'static, str>>>(self, event: T) -> Self
[src]
Sets the event type of the event. Like set_id
, it returns self
and so can easily be
chained.
pub fn to_sse(&self) -> String
[src]
Converts the Event to an SSE string.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Event
impl Send for Event
impl Sync for Event
impl Unpin for Event
impl UnwindSafe for Event
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,