pub struct OutputStore(/* private fields */);Expand description
Stores the outputs too large for a result, each in a file named by a word
leased from the store’s AnyIdAllocator.
A stored output is addressed by its path for as long as the store lives, so its word stays leased until the last clone of the store drops. A word naming a file already in the directory, left by an earlier store, is skipped whatever that file’s extension, so one word never names two files.
Implementations§
Source§impl OutputStore
impl OutputStore
Sourcepub async fn new(
dir: impl Into<PathBuf>,
ids: AnyIdAllocator,
policy: OutputPolicy,
wording: AnyShellWording,
) -> Result<Self>
pub async fn new( dir: impl Into<PathBuf>, ids: AnyIdAllocator, policy: OutputPolicy, wording: AnyShellWording, ) -> Result<Self>
Creates an output store in dir, naming its files with words leased
from ids, cutting outputs at the limits of policy and rendering
the markers of what it cuts through wording.
§Errors
Returns an error if the directory cannot be created.
Sourcepub fn policy(&self) -> &OutputPolicy
pub fn policy(&self) -> &OutputPolicy
The limits this store cuts outputs at.
Sourcepub fn wording(&self) -> &AnyShellWording
pub fn wording(&self) -> &AnyShellWording
What renders the markers of the views this store cuts.
Sourcepub async fn save(
&self,
data: &[u8],
format: OutputFormat,
resolution: MediaResolution,
) -> Result<CommandStream>
pub async fn save( &self, data: &[u8], format: OutputFormat, resolution: MediaResolution, ) -> Result<CommandStream>
Saves output data and returns the stream the result carries.
Cuts at the inline_bytes of the store’s output policy:
- Empty data → an empty
Inlinestream - Below limit →
Inline(shown directly) - Above limit →
Stored(file created, preview kept for text) - Images →
Image(always a file)
§Errors
Returns an error if file creation fails.
Sourcepub async fn save_with_limit(
&self,
data: &[u8],
format: OutputFormat,
resolution: MediaResolution,
limit: Option<usize>,
) -> Result<CommandStream>
pub async fn save_with_limit( &self, data: &[u8], format: OutputFormat, resolution: MediaResolution, limit: Option<usize>, ) -> Result<CommandStream>
Saves output data with an explicit size limit.
When output exceeds the limit, it’s saved to file and only a reference is returned. The LLM must use head/tail/rg to read the file content like a human.
§Errors
Returns an error if file creation fails.
Sourcepub async fn save_text_with_line_limit(
&self,
data: &[u8],
format: OutputFormat,
resolution: MediaResolution,
max_lines: usize,
byte_limit: Option<usize>,
) -> Result<CommandStream>
pub async fn save_text_with_line_limit( &self, data: &[u8], format: OutputFormat, resolution: MediaResolution, max_lines: usize, byte_limit: Option<usize>, ) -> Result<CommandStream>
Saves text output with a line-count limit.
When the output exceeds max_lines (or the byte limit), the full content
is saved to a file and the returned content carries a head+tail preview
within the caller’s budget plus the file reference and read guidance.
§Errors
Returns an error if file creation fails.
Sourcepub async fn save_raw(&self, data: &[u8]) -> Result<(String, PathBuf)>
pub async fn save_raw(&self, data: &[u8]) -> Result<(String, PathBuf)>
Saves raw data to a file without any processing, returning its URL and absolute path.
Used to preserve the original of a lossy compression stage alongside the reduced version the model reads, and to create the file a background job’s output is redirected to.
§Errors
Returns an error if file creation fails.
Trait Implementations§
Source§impl Clone for OutputStore
impl Clone for OutputStore
Auto Trait Implementations§
impl !RefUnwindSafe for OutputStore
impl !UnwindSafe for OutputStore
impl Forget for OutputStore
impl Freeze for OutputStore
impl Move for OutputStore
impl Send for OutputStore
impl Sync for OutputStore
impl Unpin for OutputStore
impl UnsafeUnpin for OutputStore
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
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> 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