Skip to main content

OutputStore

Trait OutputStore 

Source
pub trait OutputStore: Send + Sync {
    // Required method
    fn create(&self, ctx: &dyn ToolContext, command: &str) -> Result<OutputFile>;
}
Expand description

Keeps the full output of bash commands whose result is cut (spec 3.1 §10 D10).

The harness keeps each file in the session’s scratch directory and reads it back with shell_output; without a store, a cut result names only the bytes it left out.

§Example

use adk_core::ToolContext;
use adk_devtools::{OutputFile, OutputStore};

struct InDir(std::path::PathBuf);

impl OutputStore for InDir {
    fn create(&self, ctx: &dyn ToolContext, _command: &str) -> std::io::Result<OutputFile> {
        let id = ctx.function_call_id().to_string();
        let path = self.0.join(format!("{id}.log"));
        let file = std::fs::File::options().write(true).create_new(true).open(&path)?;
        Ok(OutputFile { id, path, file })
    }
}

Required Methods§

Source

fn create(&self, ctx: &dyn ToolContext, command: &str) -> Result<OutputFile>

Creates a new, empty file for the output of command, run by the call ctx.

§Errors

Returns the I/O error when the file cannot be created; the result then names only the bytes it left out.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§