pub struct Event { /* private fields */ }Available on crate feature
server only.Expand description
Message of Sse. Each event has some lines of specified fields including event, data,
id, retry and comment.
Implementations§
Source§impl Event
impl Event
Sourcepub fn event<T>(self, event: T) -> Self
pub fn event<T>(self, event: T) -> Self
Set the event field (event: <event-name>) for the event message.
§Panics
- Panics if the event field has already set.
- Panics if the event name contains
\ror\n.
Sourcepub fn data<T>(self, data: T) -> Self
pub fn data<T>(self, data: T) -> Self
Set the data field(s) (data: <content>) for the event message.
Each line of contents will be added data: prefix when sending.
§Panics
- Panics if the data field has already set through
Self::dataorSelf::json.
Sourcepub fn json<T>(self, data: &T) -> Result<Self, Error>where
T: Serialize,
Available on crate feature json only.
pub fn json<T>(self, data: &T) -> Result<Self, Error>where
T: Serialize,
json only.Set the data field (data: <content>) by serialized data for the event message.
Each line of contents will be added data: prefix when sending.
§Panics
- Panics if the data field has already set through
Self::dataorSelf::json.
Sourcepub fn id<T>(self, id: T) -> Self
pub fn id<T>(self, id: T) -> Self
Set the id field (id: <id>) for the event message.
§Panics
- Panics if the id field has already set.
- Panics if the id contains
\ror\n.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Event
impl RefUnwindSafe for Event
impl Send for Event
impl Sync for Event
impl Unpin for Event
impl UnwindSafe for Event
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