Skip to main content

LazyContext

Trait LazyContext 

Source
pub trait LazyContext: Send + Sync {
    // Required methods
    fn provider(&self) -> &Arc<dyn IDatabaseProvider>;
    fn owner_snapshot(&self) -> &HashMap<String, DbValue>;
    fn owner_key_values(&self) -> &HashMap<String, DbValue>;
    fn navigation(&self) -> &NavigationMeta;
    fn filter_map(&self) -> Option<&HashMap<String, CompiledFilter>>;
    fn depth(&self) -> usize;
}
Expand description

Context attached to a navigation container enabling deferred loading.

Stored as Arc<dyn LazyContext> inside BelongsTo<T> / HasMany<T> / HasOne<T>. The context carries everything load() needs to build and execute a single-entity navigation query:

  • The database provider (for connection + SQL generation)
  • The owning entity’s primary-key values and full property snapshot
  • The NavigationMeta describing which navigation to load
  • Optional global query filters (e.g. tenant isolation)
  • The current recursion depth (for cycle detection)

Implemented by LazyContextImpl; users can provide custom implementations for advanced scenarios (e.g. custom caching).

Required Methods§

Source

fn provider(&self) -> &Arc<dyn IDatabaseProvider>

The database provider used to execute the lazy-load query.

Source

fn owner_snapshot(&self) -> &HashMap<String, DbValue>

The owning entity’s full property snapshot (field_name → value).

Used to extract foreign-key values for BelongsTo navigations.

Source

fn owner_key_values(&self) -> &HashMap<String, DbValue>

The owning entity’s primary-key values (field_name → value).

Used to extract principal-key values for HasMany / HasOne navigations.

Source

fn navigation(&self) -> &NavigationMeta

Metadata describing the navigation to lazy-load.

Source

fn filter_map(&self) -> Option<&HashMap<String, CompiledFilter>>

Optional global query filters keyed by table name.

Applied to the related table’s query so lazy-loaded data respects the same scoping (e.g. tenant isolation) as top-level queries.

Source

fn depth(&self) -> usize

Current recursion depth (0 = top-level lazy load).

Incremented each time load() materializes child entities and attaches new lazy contexts to them.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§