pub struct MirrorStore { /* private fields */ }Expand description
Persistent local mirror of remote API data.
Implementations§
Source§impl MirrorStore
impl MirrorStore
Sourcepub async fn in_memory() -> Result<Self>
pub async fn in_memory() -> Result<Self>
Open an in-memory mirror — useful for tests and short-lived agents.
Sourcepub fn pool(&self) -> &SqlitePool
pub fn pool(&self) -> &SqlitePool
Direct access to the underlying pool — handy for ad-hoc admin tasks.
Most callers want Self::query instead, which is read-only.
Sourcepub async fn migrate_to(&self, target_version: Option<i64>) -> Result<()>
pub async fn migrate_to(&self, target_version: Option<i64>) -> Result<()>
Migrate the schema to the latest version (or a specific target).
Sourcepub async fn register_resource(&self, name: &str) -> Result<()>
pub async fn register_resource(&self, name: &str) -> Result<()>
Register a resource name so it appears in Self::list_resources.
Idempotent — calling twice is a no-op.
Sourcepub async fn list_resources(&self) -> Result<Vec<String>>
pub async fn list_resources(&self) -> Result<Vec<String>>
List every resource that has been registered or seen via apply_delta.
Sourcepub async fn apply_delta(
&self,
delta: &Delta,
strategy: &dyn ConflictStrategy,
) -> Result<AppliedDelta>
pub async fn apply_delta( &self, delta: &Delta, strategy: &dyn ConflictStrategy, ) -> Result<AppliedDelta>
Apply a delta through strategy. The delta is always recorded in the
event log; whether it lands in mirror_records depends on the
strategy’s ConflictResolution decision.
Sourcepub async fn get_record(
&self,
resource: &str,
record_id: &str,
) -> Result<Option<MirroredRecord>>
pub async fn get_record( &self, resource: &str, record_id: &str, ) -> Result<Option<MirroredRecord>>
Fetch a single record by (resource, record_id).
Sourcepub async fn list_records(&self, resource: &str) -> Result<Vec<MirroredRecord>>
pub async fn list_records(&self, resource: &str) -> Result<Vec<MirroredRecord>>
List every record for a resource.
Sourcepub async fn record_counts(&self) -> Result<Vec<(String, i64)>>
pub async fn record_counts(&self) -> Result<Vec<(String, i64)>>
Count records per resource — useful for dashboards / smoke tests.
Sourcepub async fn event_count(&self, resource: &str) -> Result<i64>
pub async fn event_count(&self, resource: &str) -> Result<i64>
Event count per resource.
Sourcepub async fn get_cursor(
&self,
source: &str,
resource: &str,
) -> Result<Option<String>>
pub async fn get_cursor( &self, source: &str, resource: &str, ) -> Result<Option<String>>
Get the cursor for (source, resource), if one has been persisted.
Sourcepub async fn set_cursor(
&self,
source: &str,
resource: &str,
cursor: Option<&str>,
) -> Result<()>
pub async fn set_cursor( &self, source: &str, resource: &str, cursor: Option<&str>, ) -> Result<()>
Persist a cursor for (source, resource).
Trait Implementations§
Source§impl Clone for MirrorStore
impl Clone for MirrorStore
Source§fn clone(&self) -> MirrorStore
fn clone(&self) -> MirrorStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for MirrorStore
impl !RefUnwindSafe for MirrorStore
impl Send for MirrorStore
impl Sync for MirrorStore
impl Unpin for MirrorStore
impl UnsafeUnpin for MirrorStore
impl !UnwindSafe for MirrorStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more