Skip to main content

Crate atoxide_parts

Crate atoxide_parts 

Source
Expand description

Part database interface for the Ato electronics compiler.

This crate provides traits and types for querying electronic component databases like JLCPCB/LCSC, Digikey, and others. It enables part selection based on solved parameter constraints from the constraint solver.

§Overview

The part selection process works as follows:

  1. The constraint solver produces parameter bounds (e.g., resistance within 9.5k-10.5k ohm)
  2. A PartQuery is constructed from these constraints
  3. A PartDatabase implementation queries a parts API or local database
  4. A PartSelector scores and ranks the matching parts
  5. The best matching part is selected

§Main Types

  • Part - A component part with parameters, package, and availability info
  • PartId - Unique identifier for a part (supplier + part number)
  • PartQuery - Query criteria for finding matching parts
  • PartDatabase - Trait for querying part databases
  • PartSelector - Trait for ranking/selecting parts
  • LcscClient - LCSC/JLCPCB API client implementation
  • PartCache - SQLite cache for offline-first operation

§Example

use atoxide_parts::{PartQuery, ResistorQuery, ParameterConstraint, ComponentType};

// Create a query for a 10k resistor in 0402 package
let query = ResistorQuery::new()
    .resistance_range(9500.0, 10500.0)  // 10k +/- 5%
    .package("0402")
    .power(0.0625)  // 1/16W minimum
    .tolerance(1.0)  // 1% or better
    .build();

// Or build a query directly
let query = PartQuery::resistor()
    .with_package("0402")
    .with_resistance(ParameterConstraint::between(9500.0, 10500.0))
    .with_min_stock(100)
    .with_limit(10);

§Database Implementations

  • LCSC: The LcscClient connects to the LCSC/JLCPCB component database
  • Cached: The CachedDatabase wraps any database with SQLite caching

Modules§

prelude
Prelude module for convenient imports.

Structs§

Availability
Stock and availability information.
BasicPartSelector
A simple part selector that uses basic scoring.
CachedDatabase
A cached database that wraps another database and caches results.
CapacitorQuery
Builder for creating capacitor queries with common parameters.
LcscClient
LCSC database client.
Manufacturer
Manufacturer information for a part.
Package
Physical package/footprint information.
Part
A component part from a part database.
PartCache
SQLite-backed part cache.
PartId
A unique identifier for a part from a specific supplier.
PartParameters
Electrical parameters for a part.
PartQuery
A query for finding parts in a database.
PartSelection
A part selection result from the picker.
PriceTier
Price tier for quantity-based pricing.
ResistorQuery
Builder for creating resistor queries with common parameters.
SelectionConfig
Configuration for part selection.

Enums§

ComponentType
The type of component being searched for.
DatabaseError
Errors that can occur when querying a part database.
ParameterConstraint
A constraint on a parameter value.
ParameterValue
A parameter value that can be matched against constraints.
PartClass
Part classification for pricing purposes.
SelectionStrategy
Strategy for selecting among multiple matching parts.

Traits§

PartDatabase
Trait for querying part databases.
PartSelector
Trait for part selection/picking logic.

Type Aliases§

DatabaseResult
Result type for database operations.