pub struct Event { /* private fields */ }
Expand description

Server-sent event

Implementations

Set the event’s data data field(s) (data:<content>)

Newlines in data will automatically be broken across data: fields.

This corresponds to MessageEvent’s data field.

Panics

Panics if data contains any carriage returns, as they cannot be transmitted over SSE.

This is supported on crate feature json only.

Set the event’s data field to a value serialized as unformatted JSON (data:<content>).

This corresponds to MessageEvent’s data field.

Set the event’s comment field (:<comment-text>).

This field will be ignored by most SSE clients.

Panics

Panics if comment contains any newlines or carriage returns, as they are not allowed in comments.

Set the event’s name field (event:<event-name>).

This corresponds to the type parameter given when calling addEventListener on an EventSource. For example, .event("update") should correspond to .addEventListener("update", ...). If no event type is given, browsers will fire a message event instead.

Panics

Panics if event contains any newlines or carriage returns.

Set the event’s retry timeout field (retry:<timeout>).

This sets how long clients will wait before reconnecting if they are disconnected from the SSE endpoint. Note that this is just a hint: clients are free to wait for longer if they wish, such as if they implement exponential backoff.

Set the event’s identifier field (id:<identifier>).

This corresponds to MessageEvent’s lastEventId field. If no ID is in the event itself, the browser will set that field to the last known message ID, starting with the empty string.

Panics

Panics if id contains any newlines, carriage returns or null characters.

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more

Should always be Self

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more