diskann_benchmark_runner/lib.rs
1/*
2 * Copyright (c) Microsoft Corporation.
3 * Licensed under the MIT license.
4 */
5
6//! A moderately functional utility for making simple benchmarking CLI applications.
7
8mod checker;
9mod jobs;
10mod result;
11
12pub mod any;
13pub mod app;
14pub mod dispatcher;
15pub mod files;
16pub mod output;
17pub mod registry;
18pub mod utils;
19
20pub use any::Any;
21pub use app::App;
22pub use checker::{CheckDeserialization, Checker};
23pub use output::Output;
24pub use result::Checkpoint;
25
26#[cfg(any(test, feature = "test-app"))]
27pub mod test;
28
29//-------//
30// Input //
31//-------//
32
33pub trait Input {
34 /// Return the discriminant associated with this type.
35 ///
36 /// This is used to map inputs types to their respective parsers.
37 ///
38 /// Well formed implementations should always return the same result.
39 fn tag(&self) -> &'static str;
40
41 /// Attempt to deserialize an opaque object from the raw `serialized` representation.
42 ///
43 /// Deserialized values can be constructed and returned via [`Checker::any`].
44 fn try_deserialize(
45 &self,
46 serialized: &serde_json::Value,
47 checker: &mut Checker,
48 ) -> anyhow::Result<Any>;
49
50 /// Print an example JSON representation of objects this input is expected to parse.
51 ///
52 /// Well formed implementations should passing the returned [`serde_json::Value`] back
53 /// to [`Self::try_deserialize`] correctly deserializes, though it need not necessarily
54 /// pass [`CheckDeserialization`].
55 fn example(&self) -> anyhow::Result<serde_json::Value>;
56}