pub struct Event { /* private fields */ }Expand description
Events are a concrete implementation of the Eventable trait.
Implementations§
Source§impl Event
impl Event
Sourcepub fn data_mut(&mut self) -> Option<&mut Cow<'static, str>>
pub fn data_mut(&mut self) -> Option<&mut Cow<'static, str>>
Mutably borrow the data for this event
Sourcepub fn set_data(&mut self, data: impl Into<Cow<'static, str>>) -> &mut Self
pub fn set_data(&mut self, data: impl Into<Cow<'static, str>>) -> &mut Self
Sets the data for this event, returning &mut Self for chaining
Sourcepub fn with_data(self, data: impl Into<Cow<'static, str>>) -> Self
pub fn with_data(self, data: impl Into<Cow<'static, str>>) -> Self
Owned chainable setter for the data for this event, returning Self
Sourcepub fn comment_mut(&mut self) -> Option<&mut Cow<'static, str>>
pub fn comment_mut(&mut self) -> Option<&mut Cow<'static, str>>
Mutably borrow a comment for this event
Sourcepub fn set_comment(
&mut self,
comment: impl Into<Cow<'static, str>>,
) -> &mut Self
pub fn set_comment( &mut self, comment: impl Into<Cow<'static, str>>, ) -> &mut Self
Sets a comment for this event, returning &mut Self for chaining
Sourcepub fn with_comment(self, comment: impl Into<Cow<'static, str>>) -> Self
pub fn with_comment(self, comment: impl Into<Cow<'static, str>>) -> Self
Owned chainable setter for a comment for this event, returning Self
Sourcepub fn event_type(&self) -> Option<&str>
pub fn event_type(&self) -> Option<&str>
Borrows the type for this event
Sourcepub fn type_mut(&mut self) -> Option<&mut Cow<'static, str>>
pub fn type_mut(&mut self) -> Option<&mut Cow<'static, str>>
Mutably borrow the type for this event
Sourcepub fn set_type(
&mut self,
event_type: impl Into<Cow<'static, str>>,
) -> &mut Self
pub fn set_type( &mut self, event_type: impl Into<Cow<'static, str>>, ) -> &mut Self
Sets the type for this event, returning &mut Self for chaining
Sourcepub fn with_type(self, event_type: impl Into<Cow<'static, str>>) -> Self
pub fn with_type(self, event_type: impl Into<Cow<'static, str>>) -> Self
Owned chainable setter for the type for this event, returning Self
Sourcepub fn id_mut(&mut self) -> Option<&mut Cow<'static, str>>
pub fn id_mut(&mut self) -> Option<&mut Cow<'static, str>>
Mutably borrow the id for this event
Sourcepub fn set_id(&mut self, id: impl Into<Cow<'static, str>>) -> &mut Self
pub fn set_id(&mut self, id: impl Into<Cow<'static, str>>) -> &mut Self
Sets the id for this event, returning &mut Self for chaining
Sourcepub fn with_id(self, id: impl Into<Cow<'static, str>>) -> Self
pub fn with_id(self, id: impl Into<Cow<'static, str>>) -> Self
Owned chainable setter for the id for this event, returning Self
Sourcepub fn retry_mut(&mut self) -> Option<&mut Duration>
pub fn retry_mut(&mut self) -> Option<&mut Duration>
Mutably borrow reconnection time for this stream
Sourcepub fn set_retry(&mut self, retry: Duration) -> &mut Self
pub fn set_retry(&mut self, retry: Duration) -> &mut Self
Sets reconnection time for this stream, returning &mut Self for chaining
Sourcepub fn with_retry(self, retry: Duration) -> Self
pub fn with_retry(self, retry: Duration) -> Self
Owned chainable setter for reconnection time for this stream, returning Self
Source§impl Event
impl Event
Sourcepub fn new(data: impl Into<Cow<'static, str>>) -> Self
pub fn new(data: impl Into<Cow<'static, str>>) -> Self
builds a new Event
by default, this event has no event type. to set an event type,
use Event::with_type or Event::set_type
Sourcepub fn new_comment(comment: impl Into<Cow<'static, str>>) -> Self
pub fn new_comment(comment: impl Into<Cow<'static, str>>) -> Self
builds a new comment-only Event, with no data
Clients ignore comments and dispatch no event for this message. Sending one periodically keeps an otherwise idle event stream from being closed by intermediaries.
let event = trillium_sse::Event::new_comment("heartbeat");
assert_eq!(event.comment(), Some("heartbeat"));
assert_eq!(event.data(), None);Trait Implementations§
impl Eq for Event
Source§impl Eventable for Event
impl Eventable for Event
impl StructuralPartialEq for Event
Auto Trait Implementations§
impl Freeze for Event
impl RefUnwindSafe for Event
impl Send for Event
impl Sync for Event
impl Unpin for Event
impl UnsafeUnpin 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
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.