AimDbInner

Struct AimDbInner 

Source
pub struct AimDbInner {
    pub records: BTreeMap<TypeId, Box<dyn AnyRecord>>,
}
Expand description

Internal database state

Holds the registry of typed records, indexed by TypeId.

Fields§

§records: BTreeMap<TypeId, Box<dyn AnyRecord>>

Map from TypeId to type-erased records (SPMC buffers for internal data flow)

Implementations§

Source§

impl AimDbInner

Source

pub fn get_typed_record<T, R>(&self) -> DbResult<&TypedRecord<T, R>>
where T: Send + 'static + Debug + Clone, R: Spawn + 'static,

Helper to get a typed record from the registry

This encapsulates the common pattern of:

  1. Getting TypeId for type T
  2. Looking up the record in the map
  3. Downcasting to the typed record
Source

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

Collects metadata for all registered records (std only)

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

Source

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

Try to get record’s latest value as JSON by record name (std only)

Searches for a record with the given name and returns its current value serialized to JSON. Returns None if:

  • Record not found
  • Record not configured with .with_serialization()
  • No value available in the atomic snapshot
§Arguments
  • record_name - The full Rust type name (e.g., “server::Temperature”)
§Returns

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

Source

pub fn set_record_from_json( &self, record_name: &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_name - The full Rust type name (e.g., “server::AppConfig”)
  • json_value - JSON representation of the value
§Returns
  • Ok(()) - Successfully set the value
  • Err(DbError) - If record not found, has producers, or deserialization fails
§Errors
  • RecordNotFound - Record with given name doesn’t exist
  • PermissionDenied - Record has active producers (safety check)
  • RuntimeError - Record not configured with .with_serialization()
  • JsonWithContext - JSON deserialization failed (schema mismatch)
§Example (internal use - called by remote access protocol)
let json_val = serde_json::json!({"log_level": "debug", "version": "1.0"});
db.set_record_from_json("server::AppConfig", json_val)?;

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.