pub struct OpenStreamWriter { /* private fields */ }Expand description
Minimal CEP-41 producer/writer.
Implementations§
Source§impl OpenStreamWriter
impl OpenStreamWriter
Sourcepub fn new(options: OpenStreamWriterOptions) -> Self
pub fn new(options: OpenStreamWriterOptions) -> Self
Create a new writer from explicit options.
Sourcepub fn progress_token(&self) -> &str
pub fn progress_token(&self) -> &str
The stream id (stringified progressToken).
Sourcepub fn is_active(&self) -> bool
pub fn is_active(&self) -> bool
Whether the writer is still live (not yet closed/aborted).
true for any freshly-created writer; see has_started.
Sourcepub fn has_started(&self) -> bool
pub fn has_started(&self) -> bool
Whether the writer has begun streaming by publishing its start frame.
Distinct from is_active: used to tell apart writers a
tool actually streams through from ones created only because the request
carried a progress token (the response-deferral guard).
Sourcepub async fn start(&self) -> Result<()>
pub async fn start(&self) -> Result<()>
Explicitly publish the start frame (idempotent; lazy on first write).
Sourcepub async fn write(&self, data: String) -> Result<()>
pub async fn write(&self, data: String) -> Result<()>
Publish one ordered chunk frame, starting the stream lazily.
Sourcepub async fn ping(&self) -> Result<()>
pub async fn ping(&self) -> Result<()>
Publish a keepalive ping carrying a fresh {token}:{n} nonce.
Sourcepub async fn pong(&self, nonce: String) -> Result<()>
pub async fn pong(&self, nonce: String) -> Result<()>
Publish a pong echoing the peer’s ping nonce.
Sourcepub async fn close(&self) -> Result<()>
pub async fn close(&self) -> Result<()>
Close the stream gracefully. Declares lastChunkIndex iff any chunks were
written. Runs on_close after the
frame is published (even on publish failure); propagates the publish error.
Sourcepub async fn abort(&self, reason: Option<String>) -> Result<()>
pub async fn abort(&self, reason: Option<String>) -> Result<()>
Abort the stream (terminal). Claims the terminal transition without the op
lock, so it never waits on a stuck write. Runs
on_abort after the frame is
published (even on publish failure); propagates the publish error.
Idempotent: a second abort (or one after close) is a no-op.
Trait Implementations§
Source§impl Clone for OpenStreamWriter
impl Clone for OpenStreamWriter
Source§fn clone(&self) -> OpenStreamWriter
fn clone(&self) -> OpenStreamWriter
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for OpenStreamWriter
impl !UnwindSafe for OpenStreamWriter
impl Freeze for OpenStreamWriter
impl Send for OpenStreamWriter
impl Sync for OpenStreamWriter
impl Unpin for OpenStreamWriter
impl UnsafeUnpin for OpenStreamWriter
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more