Skip to main content

sim_lib_openai_server/storage/
trait.rs

1use sim_kernel::{ContentId, Result};
2
3use crate::objects::{GatewayEvent, GatewayRequest, GatewayResponse, GatewayRun};
4
5/// Content-addressed store for the gateway's eval-pipeline records.
6///
7/// Each record is keyed by its [`ContentId`], so writing the same value twice
8/// is idempotent. Concrete backends implement this trait over in-memory maps
9/// or SIM tables.
10pub trait GatewayStore {
11    /// Stores a request under its content id.
12    fn put_request(&mut self, id: ContentId, request: GatewayRequest) -> Result<()>;
13    /// Returns the request stored under `id`, if present.
14    fn request(&self, id: &ContentId) -> Option<GatewayRequest>;
15
16    /// Stores a run under its content id.
17    fn put_run(&mut self, id: ContentId, run: GatewayRun) -> Result<()>;
18    /// Returns the run stored under `id`, if present.
19    fn run(&self, id: &ContentId) -> Option<GatewayRun>;
20
21    /// Stores an event under its content id.
22    fn put_event(&mut self, id: ContentId, event: GatewayEvent) -> Result<()>;
23    /// Returns the event stored under `id`, if present.
24    fn event(&self, id: &ContentId) -> Option<GatewayEvent>;
25
26    /// Stores a response under its content id.
27    fn put_response(&mut self, id: ContentId, response: GatewayResponse) -> Result<()>;
28    /// Returns the response stored under `id`, if present.
29    fn response(&self, id: &ContentId) -> Option<GatewayResponse>;
30}