nlbn 1.0.22

Fast and reliable EasyEDA/LCSC to KiCad converter with batch processing support
Documentation
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ComponentData {
    pub lcsc_id: String,
    pub title: String,
    pub data_str: Vec<String>,
    pub bbox_x: f64,  // Symbol bbox
    pub bbox_y: f64,  // Symbol bbox
    pub package_detail: Vec<String>,
    pub package_bbox_x: f64,  // Footprint bbox
    pub package_bbox_y: f64,  // Footprint bbox
    pub model_3d: Option<Model3dInfo>,
    pub manufacturer: String,
    pub datasheet: String,
    pub jlc_id: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Model3dInfo {
    pub uuid: String,
    pub title: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ApiResponse {
    pub success: bool,
    pub result: Option<ApiResult>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ApiResult {
    #[serde(rename = "dataStr")]
    pub data_str: Option<serde_json::Value>,
    pub title: Option<String>,
    #[serde(rename = "packageDetail")]
    pub package_detail: Option<serde_json::Value>,
    pub lcsc: Option<serde_json::Value>,
}

// EasyEDA Symbol structures
#[derive(Debug, Clone)]
pub struct EeSymbol {
    pub name: String,
    pub prefix: String,
    pub pins: Vec<EePin>,
    pub rectangles: Vec<EeRectangle>,
    pub circles: Vec<EeCircle>,
    pub ellipses: Vec<EeEllipse>,
    pub arcs: Vec<EeArc>,
    pub polylines: Vec<EePolyline>,
    pub polygons: Vec<EePolygon>,
    pub paths: Vec<EePath>,
    pub texts: Vec<EeText>,
}

#[derive(Debug, Clone)]
pub struct EePin {
    pub number: String,
    pub name: String,
    pub x: f64,
    pub y: f64,
    pub rotation: i32,
    pub length: f64,
    pub name_visible: bool,
    pub number_visible: bool,
    pub electric_type: String,
    pub dot: bool,
    pub clock: bool,
}

#[derive(Debug, Clone)]
pub struct EeRectangle {
    pub x: f64,
    pub y: f64,
    pub width: f64,
    pub height: f64,
    pub stroke_width: f64,
    pub fill: bool,
    pub layer_id: i32,
}

#[derive(Debug, Clone)]
pub struct EeCircle {
    pub cx: f64,
    pub cy: f64,
    pub radius: f64,
    pub stroke_width: f64,
    pub fill: bool,
    pub layer_id: i32,
}

#[derive(Debug, Clone)]
pub struct EeEllipse {
    pub cx: f64,
    pub cy: f64,
    pub rx: f64,
    pub ry: f64,
    pub stroke_width: f64,
    pub fill: bool,
}

#[derive(Debug, Clone)]
pub struct EeArc {
    pub x: f64,
    pub y: f64,
    pub radius: f64,
    pub start_angle: f64,
    pub end_angle: f64,
    pub stroke_width: f64,
}

#[derive(Debug, Clone)]
pub struct EeFootprintArc {
    pub stroke_width: f64,
    pub layer_id: i32,
    pub path: String,  // SVG path string: "M startX startY A rx ry rotation large_arc sweep endX endY"
}

#[derive(Debug, Clone)]
pub struct EePolyline {
    pub points: Vec<(f64, f64)>,
    pub stroke_width: f64,
}

#[derive(Debug, Clone)]
pub struct EePolygon {
    pub points: Vec<(f64, f64)>,
    pub stroke_width: f64,
    pub fill: bool,
}

#[derive(Debug, Clone)]
pub struct EePath {
    pub path_data: String,  // SVG path string (e.g., "M 0,0 L 10,10")
    pub stroke_width: f64,
    pub fill: bool,
}

#[derive(Debug, Clone)]
pub struct EeText {
    pub text: String,
    pub x: f64,
    pub y: f64,
    pub rotation: i32,
    pub font_size: f64,
    pub stroke_width: f64,
    pub layer_id: i32,
}

// EasyEDA Footprint structures
#[derive(Debug, Clone)]
pub struct EeFootprint {
    pub name: String,
    pub pads: Vec<EePad>,
    pub tracks: Vec<EeTrack>,
    pub circles: Vec<EeCircle>,
    pub arcs: Vec<EeFootprintArc>,
    pub rectangles: Vec<EeRectangle>,
    pub texts: Vec<EeText>,
    pub holes: Vec<EeHole>,
    pub vias: Vec<EeVia>,
    pub svg_nodes: Vec<EeSvgNode>,
}

#[derive(Debug, Clone)]
pub struct EePad {
    pub number: String,
    pub shape: String,
    pub x: f64,
    pub y: f64,
    pub width: f64,
    pub height: f64,
    pub rotation: f64,
    pub hole_radius: Option<f64>,
    pub hole_length: Option<f64>,  // For elliptical drills
    pub points: String,  // For polygon pads
    pub layer_id: i32,
}

#[derive(Debug, Clone)]
pub struct EeTrack {
    pub stroke_width: f64,
    pub layer_id: i32,
    pub net: String,
    pub points: String,  // Space-separated coordinates: "x1 y1 x2 y2 x3 y3..."
}

#[derive(Debug, Clone)]
pub struct EeHole {
    pub x: f64,
    pub y: f64,
    pub radius: f64,  // EasyEDA stores radius, not diameter
}

#[derive(Debug, Clone)]
pub struct EeVia {
    pub x: f64,
    pub y: f64,
    pub diameter: f64,  // Pad outer diameter
    pub net: String,
    pub radius: f64,    // Hole radius (drill = radius * 2)
}

#[derive(Debug, Clone)]
pub struct EeSvgNode {
    pub path: String,
    pub stroke_width: f64,
    pub layer: String,
}