pub struct StreamRestorer { /* private fields */ }Expand description
Restores one block of streamed model text.
Text is released as soon as it cannot be part of a placeholder. A tail that
could still become one (for the default format, an open [ followed only
by placeholder characters) is held until it completes, stops matching,
grows past the longest possible placeholder, or StreamRestorer::finish
is called.
It holds no reference to the engine, so it can live inside a long-running response stream; the engine and scope are passed to each call.
Implementations§
Source§impl StreamRestorer
impl StreamRestorer
Sourcepub fn push(&mut self, engine: &Engine, scope: &ScopeId, chunk: &str) -> String
pub fn push(&mut self, engine: &Engine, scope: &ScopeId, chunk: &str) -> String
Adds a chunk and returns the restored text that is safe to send now.
Sourcepub fn finish(&mut self, engine: &Engine, scope: &ScopeId) -> String
pub fn finish(&mut self, engine: &Engine, scope: &ScopeId) -> String
Flushes any held text at the end of the block.
Sourcepub fn is_holding(&self) -> bool
pub fn is_holding(&self) -> bool
True while text is being held back.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for StreamRestorer
impl RefUnwindSafe for StreamRestorer
impl Send for StreamRestorer
impl Sync for StreamRestorer
impl Unpin for StreamRestorer
impl UnsafeUnpin for StreamRestorer
impl UnwindSafe for StreamRestorer
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
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> ⓘ
Converts
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> ⓘ
Converts
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