#[non_exhaustive]pub struct SseEvent {
pub event: String,
pub data: String,
pub id: Option<String>,
}Expand description
One SSE event.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.event: StringThe event type: the event: field, or "message" when the event
has none (as in the SSE standard).
data: StringThe data: fields, joined with \n. An event with no data:
field is never dispatched; one with an empty data: field is, with
empty data.
id: Option<String>The last event id the stream set (id:), if any. It carries over to
later events until another id: field changes it.
Implementations§
Source§impl SseEvent
impl SseEvent
Sourcepub fn new(event: impl Into<String>, data: impl Into<String>) -> Self
pub fn new(event: impl Into<String>, data: impl Into<String>) -> Self
An event with the given type and data, and no event id.
Decoders get their events from SseStream or SseDecoder; this
builds one directly, as when testing an adapter’s event mapping. Set
id afterwards for an event that carries one.
use allama_http::sse::SseEvent;
let mut event = SseEvent::new("message_delta", r#"{"type":"message_delta"}"#);
assert_eq!(event.event, "message_delta");
assert_eq!(event.id, None);
event.id = Some("42".into());Trait Implementations§
impl Eq for SseEvent
impl StructuralPartialEq for SseEvent
Auto Trait Implementations§
impl Freeze for SseEvent
impl RefUnwindSafe for SseEvent
impl Send for SseEvent
impl Sync for SseEvent
impl Unpin for SseEvent
impl UnsafeUnpin for SseEvent
impl UnwindSafe for SseEvent
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