memea::db

Struct Database

Source
pub struct Database {
    pub core: HashMap<String, Core>,
    pub logic: HashMap<String, Logic>,
    pub switch: HashMap<String, Switch>,
    pub adc: HashMap<String, ADC>,
}
Expand description

Component database containing all available peripheral elements.

The database stores collections of different component types (core cells, logic blocks, switches, and ADCs) indexed by name. It supports serialization to and from YAML and JSON formats.

§Examples

use memea::db::{Database, build_db};
use std::path::PathBuf;

// Load database from file
let db_path = PathBuf::from("components.yaml");
let db = build_db(&db_path).expect("Failed to load database");

// Access components
if let Some(core_cell) = db.core.get("sram_6t") {
    println!("Found core cell with WL drive: {}", core_cell.dx_wl);
}

Fields§

§core: HashMap<String, Core>

Collection of memory core cells indexed by name.

§logic: HashMap<String, Logic>

Collection of logic blocks indexed by name.

§switch: HashMap<String, Switch>

Collection of switch components indexed by name.

§adc: HashMap<String, ADC>

Collection of ADC components indexed by name.

Implementations§

Source§

impl Database

Source

pub fn new() -> Database

Creates a new empty database.

§Returns

A Database with empty collections for all component types

Source

pub fn add_adc(&mut self, name: &str, dims: Dims)

Adds a new ADC component to the database via interactive prompts.

§Arguments
  • name - Name identifier for the ADC
  • dims - Physical dimensions of the ADC
Source

pub fn add_core(&mut self, name: &str, dims: Dims)

Adds a new core cell to the database via interactive prompts.

§Arguments
  • name - Name identifier for the core cell
  • dims - Physical dimensions of the core cell
Source

pub fn add_logic(&mut self, name: &str, dims: Dims)

Adds a new logic block to the database via interactive prompts.

§Arguments
  • name - Name identifier for the logic block
  • dims - Physical dimensions of the logic block
Source

pub fn add_switch(&mut self, name: &str, dims: Dims)

Adds a new switch component to the database via interactive prompts.

§Arguments
  • name - Name identifier for the switch
  • dims - Physical dimensions of the switch
Source

pub fn save(&self, filename: &PathBuf, verbose: bool) -> Result<(), MemeaError>

Saves the database to a file in YAML or JSON format.

The output format is determined by the file extension (.yaml/.yml for YAML, .json for JSON).

§Arguments
  • filename - Path where the database should be saved
  • verbose - Whether to print verbose output about the save operation
§Returns
  • Ok(()) - Database was successfully saved
  • Err(MemeaError) - File I/O error or unsupported format

Trait Implementations§

Source§

impl Debug for Database

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Database

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Database

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Database

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,