pub struct Study { /* private fields */ }Expand description
Implementations§
Source§impl Study
impl Study
Sourcepub fn registered() -> Self
pub fn registered() -> Self
A study of every register_eval!-registered eval
in the binary (the #[eval] / cargo test-style discovery path).
Sourcepub fn evals(self, evals: impl IntoIterator<Item = Eval>) -> Self
pub fn evals(self, evals: impl IntoIterator<Item = Eval>) -> Self
Add many evals.
Sourcepub fn named(self, name: impl Into<String>) -> Self
pub fn named(self, name: impl Into<String>) -> Self
Override the name advertised to the host (defaults to the crate name).
Sourcepub fn page_size(self, size: usize) -> Self
pub fn page_size(self, size: usize) -> Self
Set the samples-per-page for list pagination. 0 disables pagination
(all samples are enumerated inline in list). Defaults to
DEFAULT_PAGE_SIZE; lower it to chunk a very large dataset more
aggressively, or raise it to send bigger pages.
Sourcepub async fn serve(self) -> Result<()>
pub async fn serve(self) -> Result<()>
Serve this study over newline-delimited JSON on stdin/stdout until EOF. The host drives the loop; this returns when stdin closes.
Sourcepub async fn serve_io<R, W>(self, reader: R, writer: W) -> Result<()>
pub async fn serve_io<R, W>(self, reader: R, writer: W) -> Result<()>
Serve over arbitrary line-framed transports (e.g. in-memory pipes in
tests). serve is this over real stdin/stdout.
Requests are dispatched concurrently: each run is handled on its own
task so a host can keep many cases in flight at once. Writes are serialized
through a shared writer mutex (one whole line per lock), so responses and
event/log notifications never interleave mid-line. The host bounds how
many runs are in flight (see crate::exec).
A cancel request aborts one in-flight run/execute/score by its
request id: the run’s task is dropped at its next await point and replies
with a cancelled error, so the host’s pending call resolves promptly
instead of leaking until EOF. cancel is handled inline (not on a task)
and is itself never cancellable.
Sourcepub fn list(&self) -> ListResult
pub fn list(&self) -> ListResult
Build the list advertisement from this study’s evals. Each eval carries
the first page of its samples plus a next_cursor when more remain;
the host fetches the rest with list_samples.
Sourcepub fn list_samples(
&self,
params: &ListSamplesParams,
) -> Result<ListSamplesResult, String>
pub fn list_samples( &self, params: &ListSamplesParams, ) -> Result<ListSamplesResult, String>
Answer list_samples: the page of eval’s samples beginning at cursor.
The cursor is the opaque token from a prior page (we encode it as the
next sample offset); an unknown eval or malformed cursor is an error.