pub struct SubmitOptions {
pub redis: bool,
pub redis_ttl: Option<CacheTtl>,
pub sql: bool,
pub state: Option<String>,
}Expand description
Options for controlling where data is stored.
sync-engine is a dumb byte router - it stores Vec<u8> and routes
to L1 (always), L2 (Redis), and L3 (SQL) based on these options.
Compression is the caller’s responsibility. Compress before submit if desired. This allows callers to choose their trade-offs:
- Compressed data = smaller storage, but no SQL JSON search
- Uncompressed JSON = SQL JSON functions work, larger storage
Fields§
§redis: boolStore in L2 Redis.
Default: true
redis_ttl: Option<CacheTtl>TTL for Redis key. None means no expiry.
Use CacheTtl enum values for efficient batching.
Default: None
sql: boolStore in L3 SQL (MySQL/SQLite).
Default: true
state: Option<String>Override state tag for this item.
If Some, overrides the item’s existing state.
If None, uses the item’s current state (default: “default”).
State is indexed for fast queries: SQL index + Redis SETs.
Implementations§
Source§impl SubmitOptions
impl SubmitOptions
Sourcepub fn cache(ttl: CacheTtl) -> Self
pub fn cache(ttl: CacheTtl) -> Self
Create options for Redis-only ephemeral cache with TTL.
Uses CacheTtl enum for efficient batching. Items with the same
TTL variant are batched together in a single Redis pipeline.
- Redis: yes, not compressed (searchable)
- SQL: no
§Example
use sync_engine::{SubmitOptions, CacheTtl};
// Standard 1-hour cache (batches efficiently)
let opts = SubmitOptions::cache(CacheTtl::Hour);
// 5-minute short cache
let opts = SubmitOptions::cache(CacheTtl::Short);Sourcepub fn with_state(self, state: impl Into<String>) -> Self
pub fn with_state(self, state: impl Into<String>) -> Self
Set the state for items submitted with these options (builder pattern).
§Example
use sync_engine::SubmitOptions;
let opts = SubmitOptions::default().with_state("delta");Sourcepub fn stores_anywhere(&self) -> bool
pub fn stores_anywhere(&self) -> bool
Returns true if data should be stored anywhere.
Trait Implementations§
Source§impl Clone for SubmitOptions
impl Clone for SubmitOptions
Source§fn clone(&self) -> SubmitOptions
fn clone(&self) -> SubmitOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SubmitOptions
impl Debug for SubmitOptions
Source§impl Default for SubmitOptions
impl Default for SubmitOptions
Source§impl From<&SubmitOptions> for OptionsKey
impl From<&SubmitOptions> for OptionsKey
Source§fn from(opts: &SubmitOptions) -> Self
fn from(opts: &SubmitOptions) -> Self
Source§impl From<SubmitOptions> for OptionsKey
impl From<SubmitOptions> for OptionsKey
Source§fn from(opts: SubmitOptions) -> Self
fn from(opts: SubmitOptions) -> Self
Auto Trait Implementations§
impl Freeze for SubmitOptions
impl RefUnwindSafe for SubmitOptions
impl Send for SubmitOptions
impl Sync for SubmitOptions
impl Unpin for SubmitOptions
impl UnwindSafe for SubmitOptions
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