[][src]Struct hyper_usse::EventBuilder

pub struct EventBuilder<'data, 'id, 'event> {
    pub data: &'data str,
    pub id: Option<&'id str>,
    pub event_type: Option<&'event str>,
}

A struct used to build server sent events.

Examples

Build an event with just data:

EventBuilder::new("Data").build();

Build an event with an ID:

EventBuilder::new("Data").id("Id").build();

Build an event with an event type:

EventBuilder::new("Data").event_type("update").build();

Because EventBuilder implements Into<Bytes> you don't have to call build to pass it to the server.

Fields

data: &'data strid: Option<&'id str>event_type: Option<&'event str>

Methods

impl<'data, 'id, 'event> EventBuilder<'data, 'id, 'event>[src]

pub fn new(data: &'data str) -> Self[src]

Create a new builder with data, no id and no event type.

pub fn data(self, data: &'data str) -> Self[src]

Set the data.

pub fn id(self, id: &'id str) -> Self[src]

Set the event id.

pub fn event_type(self, event_type: &'event str) -> Self[src]

Set the event type.

pub fn clear_id(self) -> Self[src]

Clear the event id.

pub fn clear_type(self) -> Self[src]

Clear the event type.

pub fn build(self) -> String[src]

Build the event.

Trait Implementations

impl<'data, 'id, 'event> Clone for EventBuilder<'data, 'id, 'event>[src]

impl<'data, 'id, 'event> Copy for EventBuilder<'data, 'id, 'event>[src]

impl<'data, 'id, 'event> Debug for EventBuilder<'data, 'id, 'event>[src]

impl<'data, 'id, 'event> Display for EventBuilder<'data, 'id, 'event>[src]

impl<'data, 'id, 'event> Eq for EventBuilder<'data, 'id, 'event>[src]

impl<'data, 'id, 'event> Into<Bytes> for EventBuilder<'data, 'id, 'event>[src]

impl<'data, 'id, 'event> PartialEq<EventBuilder<'data, 'id, 'event>> for EventBuilder<'data, 'id, 'event>[src]

impl<'data, 'id, 'event> StructuralEq for EventBuilder<'data, 'id, 'event>[src]

impl<'data, 'id, 'event> StructuralPartialEq for EventBuilder<'data, 'id, 'event>[src]

Auto Trait Implementations

impl<'data, 'id, 'event> RefUnwindSafe for EventBuilder<'data, 'id, 'event>

impl<'data, 'id, 'event> Send for EventBuilder<'data, 'id, 'event>

impl<'data, 'id, 'event> Sync for EventBuilder<'data, 'id, 'event>

impl<'data, 'id, 'event> Unpin for EventBuilder<'data, 'id, 'event>

impl<'data, 'id, 'event> UnwindSafe for EventBuilder<'data, 'id, 'event>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.