Struct trillium_sse::Event
source · pub struct Event { /* private fields */ }
Expand description
Events are a concrete implementation of the Eventable
trait.
Implementations§
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 with_type(self, event_type: impl Into<Cow<'static, str>>) -> Self
pub fn with_type(self, event_type: impl Into<Cow<'static, str>>) -> Self
chainable constructor to set the type on an event
let event = trillium_sse::Event::new("event data").with_type("userdata");
assert_eq!(event.event_type(), Some("userdata"));
assert_eq!(event.data(), "event data");
sourcepub fn set_type(&mut self, event_type: impl Into<Cow<'static, str>>)
pub fn set_type(&mut self, event_type: impl Into<Cow<'static, str>>)
set the event type for this Event. The default is None.
let mut event = trillium_sse::Event::new("event data");
assert_eq!(event.event_type(), None);
event.set_type("userdata");
assert_eq!(event.event_type(), Some("userdata"));
sourcepub fn event_type(&self) -> Option<&str>
pub fn event_type(&self) -> Option<&str>
returns this Event’s type as a str, if set
Trait Implementations§
source§impl PartialEq for Event
impl PartialEq for Event
impl Eq 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 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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more