Skip to main content

MemoryGatewayStore

Struct MemoryGatewayStore 

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

In-memory gateway store backed by BTreeMaps.

Implements GatewayStore, GatewayResponseObjectStore, and GatewayStateStore. Intended for tests and single-process use; nothing is persisted beyond the process.

Implementations§

Source§

impl MemoryGatewayStore

Source

pub fn new() -> Self

Creates an empty in-memory store.

Source

pub fn put_request_content( &mut self, request: GatewayRequest, ) -> Result<ContentId>

Stores a request under its derived content id and returns that id.

Source

pub fn put_run_content(&mut self, run: GatewayRun) -> Result<ContentId>

Stores a run under its derived content id and returns that id.

Source

pub fn put_event_content(&mut self, event: GatewayEvent) -> Result<ContentId>

Stores an event under its derived content id and returns that id.

Source

pub fn put_response_content( &mut self, response: GatewayResponse, ) -> Result<ContentId>

Stores a response under its derived content id and returns that id.

Source

pub fn counts(&self) -> GatewayStoreCounts

Returns a snapshot of the current record counts.

Source

pub fn requests(&self) -> Vec<(ContentId, GatewayRequest)>

Returns all stored requests paired with their content ids.

Source

pub fn runs(&self) -> Vec<(ContentId, GatewayRun)>

Returns all stored runs paired with their content ids.

Source

pub fn run_by_id(&self, run_id: &str) -> Option<(ContentId, GatewayRun)>

Returns the run (with its content id) whose run id matches run_id.

Source

pub fn events(&self) -> Vec<(ContentId, GatewayEvent)>

Returns all stored events paired with their content ids.

Trait Implementations§

Source§

impl Clone for MemoryGatewayStore

Source§

fn clone(&self) -> MemoryGatewayStore

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MemoryGatewayStore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MemoryGatewayStore

Source§

fn default() -> MemoryGatewayStore

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

impl GatewayResponseObjectStore for MemoryGatewayStore

Source§

fn put_response_object(&mut self, response: StoredGatewayResponse) -> Result<()>

Stores a response object, replacing any existing entry with the same id.
Source§

fn response_object(&self, response_id: &str) -> Option<StoredGatewayResponse>

Returns the response object with the given id, if present.
Source§

impl GatewayStateStore for MemoryGatewayStore

Source§

fn put_file(&mut self, file: GatewayFile, bytes: Vec<u8>) -> Result<()>

Stores a file record together with its raw bytes.
Source§

fn file(&self, file_id: &str) -> Option<GatewayFile>

Returns the file record with the given id, if present.
Source§

fn file_bytes(&self, file_id: &str) -> Option<Vec<u8>>

Returns the raw bytes for the given file id, if present.
Source§

fn put_batch(&mut self, batch: GatewayBatch) -> Result<()>

Stores a batch record, replacing any existing entry with the same id.
Source§

fn batch(&self, batch_id: &str) -> Option<GatewayBatch>

Returns the batch with the given id, if present.
Source§

fn put_thread(&mut self, thread: GatewayThread) -> Result<()>

Stores a thread record, replacing any existing entry with the same id.
Source§

fn thread(&self, thread_id: &str) -> Option<GatewayThread>

Returns the thread with the given id, if present.
Source§

fn put_thread_message(&mut self, message: GatewayThreadMessage) -> Result<()>

Appends a message to its thread.
Source§

fn thread_messages(&self, thread_id: &str) -> Vec<GatewayThreadMessage>

Returns the messages for the given thread id, in insertion order.
Source§

fn put_vector_store(&mut self, vector_store: GatewayVectorStore) -> Result<()>

Stores a vector store, replacing any existing entry with the same id.
Source§

fn vector_store(&self, vector_store_id: &str) -> Option<GatewayVectorStore>

Returns the vector store with the given id, if present.
Source§

impl GatewayStore for MemoryGatewayStore

Source§

fn put_request(&mut self, id: ContentId, request: GatewayRequest) -> Result<()>

Stores a request under its content id.
Source§

fn request(&self, id: &ContentId) -> Option<GatewayRequest>

Returns the request stored under id, if present.
Source§

fn put_run(&mut self, id: ContentId, run: GatewayRun) -> Result<()>

Stores a run under its content id.
Source§

fn run(&self, id: &ContentId) -> Option<GatewayRun>

Returns the run stored under id, if present.
Source§

fn put_event(&mut self, id: ContentId, event: GatewayEvent) -> Result<()>

Stores an event under its content id.
Source§

fn event(&self, id: &ContentId) -> Option<GatewayEvent>

Returns the event stored under id, if present.
Source§

fn put_response( &mut self, id: ContentId, response: GatewayResponse, ) -> Result<()>

Stores a response under its content id.
Source§

fn response(&self, id: &ContentId) -> Option<GatewayResponse>

Returns the response stored under id, if present.

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.