pub struct KeepAlive<T = String> { /* private fields */ }Expand description
Configure the interval between keep-alive messages, the content of each message, and the associated stream.
Implementations§
Source§impl<T> KeepAlive<T>
impl<T> KeepAlive<T>
Sourcepub fn new() -> KeepAlive<T>
pub fn new() -> KeepAlive<T>
Create a new KeepAlive.
The default frame is a single empty comment, which serializes to
:\n\n on the wire — the canonical SSE keep-alive payload. A fully
empty Event would serialize to zero bytes and convey nothing to
the client (some HTTP/2 stacks also reject empty data frames).
Source§impl<T> KeepAlive<T>where
T: EventDataWrite,
impl<T> KeepAlive<T>where
T: EventDataWrite,
Sourcepub fn with_interval(self, time: Duration) -> KeepAlive<T>
pub fn with_interval(self, time: Duration) -> KeepAlive<T>
Customize the interval between keep-alive messages.
Default is 15 seconds.
Sourcepub fn set_interval(&mut self, time: Duration) -> &mut KeepAlive<T>
pub fn set_interval(&mut self, time: Duration) -> &mut KeepAlive<T>
Customize the interval between keep-alive messages.
Default is 15 seconds.
Sourcepub fn try_with_text(
self,
text: impl Into<SmolStr>,
) -> Result<KeepAlive<T>, Box<dyn Error + Send + Sync>>
pub fn try_with_text( self, text: impl Into<SmolStr>, ) -> Result<KeepAlive<T>, Box<dyn Error + Send + Sync>>
Customize the text of the keep-alive message.
Default is an empty comment.
Sourcepub fn try_set_text(
&mut self,
text: impl Into<SmolStr>,
) -> Result<&mut KeepAlive<T>, Box<dyn Error + Send + Sync>>
pub fn try_set_text( &mut self, text: impl Into<SmolStr>, ) -> Result<&mut KeepAlive<T>, Box<dyn Error + Send + Sync>>
Customize the text of the keep-alive message.
Default is an empty comment.
Sourcepub fn with_event(self, event: Event<T>) -> KeepAlive<T>
pub fn with_event(self, event: Event<T>) -> KeepAlive<T>
Customize the event of the keep-alive message.
Default is an empty event.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for KeepAlive<T>
impl<T> RefUnwindSafe for KeepAlive<T>where
Event<T>: RefUnwindSafe,
impl<T> Send for KeepAlive<T>
impl<T> Sync for KeepAlive<T>
impl<T> Unpin for KeepAlive<T>
impl<T> UnsafeUnpin for KeepAlive<T>where
Event<T>: UnsafeUnpin,
impl<T> UnwindSafe for KeepAlive<T>where
Event<T>: UnwindSafe,
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
Source§impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for Twhere
U: RamaTryFrom<T, CrateMarker>,
impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for Twhere
U: RamaTryFrom<T, CrateMarker>,
type Error = <U as RamaTryFrom<T, CrateMarker>>::Error
fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T, CrateMarker>>::Error>
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<V, F> ValueFormatter<&V> for F
impl<V, F> ValueFormatter<&V> for F
Source§const SHAPE: FieldShape<'static>
const SHAPE: FieldShape<'static>
metrique_require_explicit_impls only.Source§fn format_value(writer: impl ValueWriter, value: &&V)
fn format_value(writer: impl ValueWriter, value: &&V)
value to writerSource§impl<V, F> ValueFormatter<Arc<V>> for F
impl<V, F> ValueFormatter<Arc<V>> for F
Source§const SHAPE: FieldShape<'static>
const SHAPE: FieldShape<'static>
metrique_require_explicit_impls only.Source§fn format_value(writer: impl ValueWriter, value: &Arc<V>)
fn format_value(writer: impl ValueWriter, value: &Arc<V>)
value to writerSource§impl<V, F> ValueFormatter<Box<V>> for F
impl<V, F> ValueFormatter<Box<V>> for F
Source§const SHAPE: FieldShape<'static>
const SHAPE: FieldShape<'static>
metrique_require_explicit_impls only.Source§fn format_value(writer: impl ValueWriter, value: &Box<V>)
fn format_value(writer: impl ValueWriter, value: &Box<V>)
value to writerSource§impl<V, F> ValueFormatter<Cow<'_, V>> for F
impl<V, F> ValueFormatter<Cow<'_, V>> for F
Source§const SHAPE: FieldShape<'static>
const SHAPE: FieldShape<'static>
metrique_require_explicit_impls only.Source§fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)
fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)
value to writerSource§impl<V, F> ValueFormatter<Option<V>> for Fwhere
F: ValueFormatter<V> + ?Sized,
impl<V, F> ValueFormatter<Option<V>> for Fwhere
F: ValueFormatter<V> + ?Sized,
Source§const SHAPE: FieldShape<'static>
const SHAPE: FieldShape<'static>
metrique_require_explicit_impls only.Source§fn format_value(writer: impl ValueWriter, value: &Option<V>)
fn format_value(writer: impl ValueWriter, value: &Option<V>)
value to writer