StateStore

Struct StateStore 

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

Main state store for managing stateful operations

Implementations§

Source§

impl StateStore

Source

pub fn new(backend: StateBackend) -> Self

Create a new state store with default config

Source

pub fn with_config(config: StateConfig) -> Self

Create a state store with custom configuration

Source

pub fn put(&mut self, key: impl Into<String>, value: Value) -> StateResult<()>

Put a value into state

Source

pub fn put_with_ttl( &mut self, key: impl Into<String>, value: Value, ttl: Duration, ) -> StateResult<()>

Put a value with custom TTL

Source

pub fn get(&self, key: &str) -> StateResult<Option<Value>>

Get a value from state

Source

pub fn update(&mut self, key: &str, value: Value) -> StateResult<()>

Update an existing value

Source

pub fn delete(&mut self, key: &str) -> StateResult<()>

Delete a value from state

Source

pub fn contains(&self, key: &str) -> bool

Check if a key exists

Source

pub fn keys(&self) -> Vec<String>

Get all keys in state

Source

pub fn clear(&mut self) -> StateResult<()>

Clear all state

Source

pub fn len(&self) -> usize

Get the number of entries in state

Source

pub fn is_empty(&self) -> bool

Check if state is empty

Source

pub fn cleanup_expired(&mut self) -> usize

Clean up expired entries

Source

pub fn checkpoint(&mut self, name: impl Into<String>) -> StateResult<String>

Create a checkpoint of current state

Source

pub fn restore(&mut self, checkpoint_id: &str) -> StateResult<()>

Restore state from a checkpoint

Source

pub fn list_checkpoints(&self) -> Vec<CheckpointMetadata>

List all checkpoints

Source

pub fn latest_checkpoint(&self) -> Option<CheckpointMetadata>

Get the latest checkpoint

Source

pub fn statistics(&self) -> StateStatistics

Get state statistics

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,