use arcstr::ArcStr;
use rust_decimal::Decimal;
pub type LayoutResult<T> = Result<T, LayoutError>;
#[derive(thiserror::Error, Debug, Clone)]
pub enum LayoutError {
#[error("error during gds export: {0:?}")]
GdsExport(GdsExportError),
#[error("error specifying layout IO")]
IoDefinition,
}
impl From<GdsExportError> for LayoutError {
fn from(e: GdsExportError) -> Self {
Self::GdsExport(e)
}
}
pub type GdsExportResult<T> = Result<T, GdsExportError>;
#[derive(thiserror::Error, Debug, Clone)]
pub enum GdsExportError {
#[error("error converting an integer to the necessary type: {0:?}")]
TryFromInt(std::num::TryFromIntError),
#[error("error writing GDS file: {0:?}")]
Write(gds::GdsError),
}
impl From<std::num::TryFromIntError> for GdsExportError {
fn from(e: std::num::TryFromIntError) -> Self {
Self::TryFromInt(e)
}
}
impl From<gds::GdsError> for GdsExportError {
fn from(e: gds::GdsError) -> Self {
Self::Write(e)
}
}
pub type GdsImportResult<T> = Result<T, GdsImportError>;
#[derive(thiserror::Error, Debug, Clone)]
pub enum GdsImportError {
#[error("error converting an integer to the necessary type: {0:?}")]
TryFromInt(#[from] std::num::TryFromIntError),
#[error("error writing GDS file: {0:?}")]
Write(#[from] gds::GdsError),
#[error("cell not found in GDS library: {0}")]
CellNotFound(ArcStr),
#[error("found more than one cell with the same name in a GDS library: {0}")]
DuplicateCell(ArcStr),
#[error("unsupported GDS feature: {0}")]
Unsupported(ArcStr),
#[error("invalid GDS boundary (boundaries must start and end at the same point)")]
InvalidGdsBoundary,
#[error("GDS file units ({0}) do not match PDK units ({1})")]
MismatchedUnits(Decimal, Decimal),
}