MemoryStore

Struct MemoryStore 

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

A FIFO data store that keeps items in memory.

Items are stored until fetched or until max_items is reached, at which point older items are removed to make space for new ones. The store maintains data in a queue structure and supports concurrent access.

When items are fetched, they are packaged into a JSON batch with metadata including:

  • A batch array containing the items
  • A timestamp indicating when the batch was created
  • The store’s write key

Implementations§

Source§

impl MemoryStore

Source

pub fn new(config: MemoryConfig) -> Self

Creates a new MemoryStore with the specified configuration.

§Panics
  • If max_fetch_size is less than 100 bytes
  • If max_items is 0

Trait Implementations§

Source§

impl DataStore for MemoryStore

Source§

type Output = Value

The type of data returned by fetch operations.
Source§

fn has_data(&self) -> bool

Checks if the store contains any data that can be fetched.
Source§

fn reset(&mut self)

Removes all data from the store and resets it to initial state.
Source§

fn append(&mut self, data: Value) -> Result<()>

Appends a new item to the store. Read more
Source§

fn fetch( &mut self, count: Option<usize>, max_bytes: Option<usize>, ) -> Result<Option<DataResult<Self::Output>>>

Fetches a batch of data from the store, respecting optional count and size limits. Read more
Source§

fn remove(&mut self, data: &[Box<dyn Equivalent>]) -> Result<()>

Removes previously fetched data from the store. Read more

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> 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.