pub struct SseStream;Expand description
Helper for configuring SSE response headers and streaming events over a Hyperlane Context.
Implementations§
Source§impl SseStream
Inherent implementation of SseStream.
impl SseStream
Inherent implementation of SseStream.
Sourcepub fn prepare(ctx: &mut Context)
pub fn prepare(ctx: &mut Context)
Configures standard SSE response headers on ctx without closing the stream.
§Arguments
&mut Context- Active Hyperlane request context.
Sourcepub async fn send_event(
stream: &mut Stream,
event: &SseEvent,
) -> Result<(), SseError>
pub async fn send_event( stream: &mut Stream, event: &SseEvent, ) -> Result<(), SseError>
Writes one SseEvent frame directly onto stream, using a zero-allocation stack buffer for frames <= 512 bytes.
§Arguments
&mut Stream- Active Hyperlane client stream.&SseEvent- Event to encode and flush.
§Returns
Result<(), SseError>-Ok(())on successful write, orSseError::Transport.
Sourcepub async fn send_event_buffered(
stream: &mut Stream,
event: &SseEvent,
scratch: &mut Vec<u8>,
) -> Result<(), SseError>
pub async fn send_event_buffered( stream: &mut Stream, event: &SseEvent, scratch: &mut Vec<u8>, ) -> Result<(), SseError>
Encodes event into a reusable scratch buffer and writes it onto stream.
§Arguments
&mut Stream- Active Hyperlane client stream.&SseEvent- Event to encode and flush.&mut Vec<u8>- Reusable frame encoding buffer.
§Returns
Result<(), SseError>-Ok(())on successful write, orSseError::Transport.
Sourcepub async fn send_comment(
stream: &mut Stream,
comment: &str,
) -> Result<(), SseError>
pub async fn send_comment( stream: &mut Stream, comment: &str, ) -> Result<(), SseError>
Writes a single SSE comment / heartbeat line directly onto stream with zero heap allocations when <= 252 bytes.
§Arguments
&mut Stream- Active Hyperlane client stream.&str- Comment text.
§Returns
Result<(), SseError>-Ok(())on successful write, orSseError::Transport.
Sourcepub async fn serve_subscription(
stream: &mut Stream,
ctx: &mut Context,
subscription: SseSubscription,
config: &SseConfig,
) -> Result<(), SseError>
pub async fn serve_subscription( stream: &mut Stream, ctx: &mut Context, subscription: SseSubscription, config: &SseConfig, ) -> Result<(), SseError>
Prepares headers, sends the HTTP head, and pumps subscription with shared heartbeats until disconnect.
§Arguments
&mut Stream- Active Hyperlane client stream.&mut Context- Active Hyperlane request context.SseSubscription- Topic subscription to stream.&SseConfig- Heartbeat and reconnect configuration.
§Returns
Result<(), SseError>- Terminates cleanly when the channel closes or client disconnects.
Auto Trait Implementations§
impl Forget for SseStream
impl Freeze for SseStream
impl Move for SseStream
impl RefUnwindSafe for SseStream
impl Send for SseStream
impl Sync for SseStream
impl Unpin for SseStream
impl UnsafeUnpin for SseStream
impl UnwindSafe for SseStream
Blanket Implementations§
impl<T> AnySend for T
impl<T> AnySendSync for T
impl<T> AnySync for T
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