refactor(specctra-core): Remove `layer_count` from `SpecctraMesadata`

This information is already stored in `Drawing`, I somehow missed that
when I was adding this field.
This commit is contained in:
Mikolaj Wielgus 2025-10-20 14:24:41 +02:00
parent 1d8745e15d
commit 1b3ecc37b1
2 changed files with 1 additions and 12 deletions

View File

@ -27,9 +27,6 @@ pub trait AccessMesadata: AccessRules + std::panic::RefUnwindSafe {
/// Retrieves the index of a layer from its name. /// Retrieves the index of a layer from its name.
fn layername_layer(&self, layername: &str) -> Option<usize>; fn layername_layer(&self, layername: &str) -> Option<usize>;
/// Return the number of the layers.
fn layer_count(&self) -> usize;
/// Renames a net based on its index. /// Renames a net based on its index.
fn bename_net(&mut self, net: usize, netname: String); fn bename_net(&mut self, net: usize, netname: String);
@ -79,9 +76,6 @@ pub struct SpecctraMesadata {
/// These rules are applied to all nets belonging to the respective net clas /// These rules are applied to all nets belonging to the respective net clas
class_rules: BTreeMap<String, SpecctraRule>, class_rules: BTreeMap<String, SpecctraRule>,
/// Number of layers.
layer_count: usize,
// layername <-> layer for Layout // layername <-> layer for Layout
/// A bidirectional map between layer indices and layer names, allowing translation /// A bidirectional map between layer indices and layer names, allowing translation
/// between index-based layers in the layout and user-defined layer names. /// between index-based layers in the layout and user-defined layer names.
@ -164,7 +158,6 @@ impl SpecctraMesadata {
structure_rule: SpecctraRule::from_dsn(&structure_rule), structure_rule: SpecctraRule::from_dsn(&structure_rule),
class_rules, class_rules,
layer_layername, layer_layername,
layer_count,
net_netname, net_netname,
net_netclass, net_netclass,
} }
@ -212,10 +205,6 @@ impl AccessMesadata for SpecctraMesadata {
self.layer_layername.get_by_right(layername).copied() self.layer_layername.get_by_right(layername).copied()
} }
fn layer_count(&self) -> usize {
self.layer_count
}
fn bename_net(&mut self, net: usize, netname: String) { fn bename_net(&mut self, net: usize, netname: String) {
self.net_netname.insert(net, netname); self.net_netname.insert(net, netname);
} }

View File

@ -12,7 +12,7 @@ pub struct Ratsnests(Box<[Ratsnest]>);
impl Ratsnests { impl Ratsnests {
pub fn new(board: &Board<impl AccessMesadata>) -> Result<Self, InsertionError> { pub fn new(board: &Board<impl AccessMesadata>) -> Result<Self, InsertionError> {
Ok(Self( Ok(Self(
(0..board.mesadata().layer_count()) (0..board.layout().drawing().layer_count())
.map(|principal_layer| Ratsnest::new(board, principal_layer)) .map(|principal_layer| Ratsnest::new(board, principal_layer))
.collect::<Result<Vec<_>, _>>() .collect::<Result<Vec<_>, _>>()
.map(Vec::into_boxed_slice)?, .map(Vec::into_boxed_slice)?,