Replace `RouteSelector` with `NetSelector`

I don't think identifying routes by pin name pair is going to be really
useful.
This commit is contained in:
Mikolaj Wielgus 2026-05-26 12:16:45 +02:00
parent 61c0134db4
commit 739bdafea2
3 changed files with 13 additions and 21 deletions

View File

@ -3,10 +3,11 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
mod component;
mod net;
mod persistable;
mod pin;
mod route;
pub use component::{ComponentSelection, ComponentSelector};
pub use net::{NetSelection, NetSelector};
pub use persistable::PersistableSelection;
pub use pin::{PinSelection, PinSelector};

View File

@ -6,32 +6,26 @@ use std::collections::BTreeSet;
use serde::{Deserialize, Serialize};
use crate::selections::PinSelector;
#[derive(Clone, Debug, Default, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
pub struct RouteSelector {
lesser_pin: PinSelector,
greater_pin: PinSelector,
pub struct NetSelector {
pub net: String,
}
impl RouteSelector {
pub fn new(pin1: PinSelector, pin2: PinSelector) -> Self {
Self {
lesser_pin: std::cmp::min(pin1.clone(), pin2.clone()),
greater_pin: std::cmp::max(pin1, pin2),
}
impl NetSelector {
pub fn new(net: String) -> Self {
Self { net }
}
}
#[derive(Clone, Debug, Default, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
pub struct RouteSelection(pub BTreeSet<RouteSelector>);
pub struct NetSelection(pub BTreeSet<NetSelector>);
impl RouteSelection {
impl NetSelection {
pub fn new() -> Self {
Default::default()
}
pub fn toggle(&mut self, selector: RouteSelector) {
pub fn toggle(&mut self, selector: NetSelector) {
if self.0.contains(&selector) {
self.0.remove(&selector);
} else {

View File

@ -4,15 +4,12 @@
use serde::{Deserialize, Serialize};
use crate::{
board::selections::{ComponentSelection, PinSelection},
selections::route::RouteSelection,
};
use crate::board::selections::{ComponentSelection, NetSelection, PinSelection};
#[derive(Clone, Debug, Default, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
pub struct PersistableSelection {
pub components: ComponentSelection,
pub routes: RouteSelection,
pub nets: NetSelection,
pub pins: PinSelection,
}
@ -20,7 +17,7 @@ impl PersistableSelection {
pub fn new() -> Self {
Self {
components: ComponentSelection::new(),
routes: RouteSelection::new(),
nets: NetSelection::new(),
pins: PinSelection::new(),
}
}