Skip to main content

AimDbInner

Struct AimDbInner 

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

Internal database state

The registry is immutable after build() and holds tens of records, so it needs exactly two structures: the entries in registration order (indexed by RecordId) and a key → id map for name resolution. The hot path (produce/consume) uses pre-resolved handles and never touches the registry; everything else here is control-plane/introspection.

Implementations§

Source§

impl AimDbInner

Source

pub fn resolve<K: RecordKey>(&self, key: &K) -> Option<RecordId>

Resolve RecordKey to RecordId (control plane - O(1) average)

Source

pub fn resolve_str(&self, name: &str) -> Option<RecordId>

Resolve string to RecordId (convenience for remote access)

O(1) average thanks to Borrow<str> implementation on RecordKey.

Source

pub fn storage(&self, id: RecordId) -> Option<&dyn AnyRecord>

Get storage by RecordId (hot path - O(1))

Source

pub fn key_for(&self, id: RecordId) -> Option<&StringKey>

Get the StringKey for a given RecordId

Source

pub fn records_of_type<T: 'static>(&self) -> Vec<RecordId>

Get all RecordIds for a type (introspection)

Linear scan — the registry is immutable after build(), holds tens of records, and this is called from introspection paths only.

Source

pub fn record_count(&self) -> usize

Get the number of registered records

Source

pub fn dependency_graph(&self) -> &DependencyGraph

Get the dependency graph (immutable reference)

The graph is constructed once during build() and never changes. Contains all record nodes, edges, and topological ordering.

Source

pub fn get_typed_record_by_key<T>( &self, key: impl AsRef<str>, ) -> DbResult<&TypedRecord<T>>
where T: Send + 'static + Debug + Clone,

Helper to get a typed record by RecordKey

This encapsulates the common pattern of:

  1. Resolving key to RecordId
  2. Validating TypeId matches
  3. Downcasting to the typed record
Source

pub fn get_typed_record_by_id<T>( &self, id: RecordId, ) -> DbResult<&TypedRecord<T>>
where T: Send + 'static + Debug + Clone,

Helper to get a typed record by RecordId with type validation

Source

pub fn list_records(&self) -> Vec<RecordMetadata>

Collects metadata for all registered records

Returns a vector of RecordMetadata for remote introspection. Available only when the remote feature is enabled.

Source

pub fn try_latest_as_json(&self, record_key: &str) -> Option<Value>

Try to get record’s latest value as JSON by record key

O(1) lookup using the key-based index.

§Arguments
  • record_key - The record key (e.g., “sensors.temperature”)
§Returns

Some(JsonValue) with the current record value, or None

Source

pub fn try_latest_as_json_bytes(&self, record_key: &str) -> Option<Vec<u8>>

Try to get a record’s latest value as owned JSON bytes.

This is the byte-oriented sibling of try_latest_as_json. The built-in Serde codec serializes the typed record directly; compatibility codecs may inherit a Value-based fallback.

Source

pub fn set_record_from_json( &self, record_key: &str, json_value: Value, ) -> DbResult<()>

Sets a record value from JSON (remote access API)

Deserializes the JSON value and writes it to the record’s buffer.

SAFETY: Enforces the “No Producer Override” rule:

  • Only works for records with producer_count == 0
  • Returns error if the record has active producers
§Arguments
  • record_key - The record key (e.g., “config.app”)
  • json_value - JSON representation of the value
§Returns
  • Ok(()) - Successfully set the value
  • Err(DbError) - If record not found, has producers, or deserialization fails

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.