Skip to main content

StreamOptions

Struct StreamOptions 

Source
pub struct StreamOptions {
    pub reconnect: bool,
    pub max_reconnects: u32,
    pub terminal_events: Vec<String>,
    pub inactivity_timeout: Option<Duration>,
    pub base_retry: Duration,
    pub max_backoff: Duration,
    pub stability_reset: Duration,
    pub on_state: Option<Arc<dyn Fn(StreamState) + Send + Sync>>,
}
Expand description

Reconnection and lifecycle behaviour for EventStream. Every field defaults to a generic, spec-compliant SSE stream; the platform-specific knobs (terminal events, an inactivity watchdog, retry: pacing) are opt-in so a caller that passes Default::default gets standard SSE.

Fields§

§reconnect: bool

Reconnect (replaying Last-Event-ID) when the stream ends. Default true.

§max_reconnects: u32

Reconnect attempts without progress before giving up. Default 5.

§terminal_events: Vec<String>

Event names that complete the stream WITHOUT reconnecting. Empty by default: a generic stream reconnects on end and lets the caller stop it.

§inactivity_timeout: Option<Duration>

Max silence between reads before the socket is presumed dead and a reconnect is attempted. None disables the watchdog (EOF owns liveness). Mirrors the platform’s 300 s inactivity timeout: collapsing it with EOF made a silently-dead socket look like a finished stream.

§base_retry: Duration

Base reconnect interval; a retry: field overrides it per stream.

§max_backoff: Duration

Cap on the reconnect backoff.

§stability_reset: Duration

Reconnect budget resets after this long connected without a disconnect, so a long healthy stream doesn’t carry “this is the Nth retry” baggage.

§on_state: Option<Arc<dyn Fn(StreamState) + Send + Sync>>

Optional connection-lifecycle observer. Disconnected is NOT fired when the caller drops the stream — only on a natural end. Held in an Arc so StreamOptions stays Clone (it lives inside the cloneable crate::RequestOptions); share state through the closure’s captures.

Trait Implementations§

Source§

impl Clone for StreamOptions

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StreamOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for StreamOptions

Source§

fn default() -> Self

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

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

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

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

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

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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