Skip to main content

Study

Struct Study 

Source
pub struct Study { /* private fields */ }
Expand description

Your eval program: a named bundle of Evals exposed to the host over the protocol. Build one, then serve it.

Implementations§

Source§

impl Study

Source

pub fn new() -> Self

An empty study. Add evals with eval / evals.

Source

pub fn registered() -> Self

A study of every register_eval!-registered eval in the binary (the #[eval] / cargo test-style discovery path).

Source

pub fn eval(self, eval: Eval) -> Self

Add one eval (builder style).

Source

pub fn evals(self, evals: impl IntoIterator<Item = Eval>) -> Self

Add many evals.

Source

pub fn named(self, name: impl Into<String>) -> Self

Override the name advertised to the host (defaults to the crate name).

Source

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.

Source

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.

Source

pub async fn serve_io<R, W>(self, reader: R, writer: W) -> Result<()>
where R: AsyncRead + Unpin, W: AsyncWrite + Send + Unpin + 'static,

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Default for Study

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Study

§

impl !UnwindSafe for Study

§

impl Freeze for Study

§

impl Send for Study

§

impl Sync for Study

§

impl Unpin for Study

§

impl UnsafeUnpin for Study

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.