pub struct PcbDoc {
pub board_params: ParameterCollection,
pub components: Vec<PcbDocComponent>,
pub primitives: Vec<PcbRecord>,
pub nets: Vec<String>,
pub rules: Vec<PcbRule>,
pub classes: Vec<PcbClass>,
pub placer_options: Option<PcbAdvancedPlacerOptions>,
pub drc_options: Option<PcbDrcOptions>,
pub pin_swap_options: Option<PcbPinSwapOptions>,
}Expand description
A PCB document containing board data.
Fields§
§board_params: ParameterCollectionBoard header parameters.
components: Vec<PcbDocComponent>Components placed on the board.
primitives: Vec<PcbRecord>Board primitives (not associated with components).
nets: Vec<String>Nets in the design.
rules: Vec<PcbRule>Design rules.
classes: Vec<PcbClass>Object classes (net classes, component classes, etc.).
placer_options: Option<PcbAdvancedPlacerOptions>Advanced placer options.
drc_options: Option<PcbDrcOptions>Design rule checker options.
pin_swap_options: Option<PcbPinSwapOptions>Pin swap options.
Implementations§
Source§impl PcbDoc
impl PcbDoc
Sourcepub fn open_file<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn open_file<P: AsRef<Path>>(path: P) -> Result<Self>
Open and read a PcbDoc file from a path.
Sourcepub fn save_to_file<P: AsRef<Path>>(&self, path: P) -> Result<()>
pub fn save_to_file<P: AsRef<Path>>(&self, path: P) -> Result<()>
Save the PcbDoc to a file path.
This performs a read-modify-write operation: it reads the existing file, updates the rules stream, and writes back to the same path.
Sourcepub fn save_board_to_file<P: AsRef<Path>>(&self, path: P) -> Result<()>
pub fn save_board_to_file<P: AsRef<Path>>(&self, path: P) -> Result<()>
Save board parameters to a file path.
This performs a read-modify-write operation: it reads the existing file, updates the Board6/Data stream, and writes back.
Sourcepub fn save_regions_to_file<P: AsRef<Path>>(&self, path: P) -> Result<()>
pub fn save_regions_to_file<P: AsRef<Path>>(&self, path: P) -> Result<()>
Save regions (keepouts/cutouts) to a file path.
This performs a read-modify-write operation.
Sourcepub fn save_polygons_to_file<P: AsRef<Path>>(&self, path: P) -> Result<()>
pub fn save_polygons_to_file<P: AsRef<Path>>(&self, path: P) -> Result<()>
Save polygons (copper pours) to a file path.
This performs a read-modify-write operation.
Sourcepub fn component_count(&self) -> usize
pub fn component_count(&self) -> usize
Get the number of components.
Sourcepub fn primitive_count(&self) -> usize
pub fn primitive_count(&self) -> usize
Get the number of primitives.
Sourcepub fn rule_count(&self) -> usize
pub fn rule_count(&self) -> usize
Get the number of design rules.
Sourcepub fn iter_rules(&self) -> impl Iterator<Item = &PcbRule>
pub fn iter_rules(&self) -> impl Iterator<Item = &PcbRule>
Iterate over design rules.
Sourcepub fn iter_rules_mut(&mut self) -> impl Iterator<Item = &mut PcbRule>
pub fn iter_rules_mut(&mut self) -> impl Iterator<Item = &mut PcbRule>
Iterate over design rules mutably.
Sourcepub fn find_rule_mut(&mut self, name: &str) -> Option<&mut PcbRule>
pub fn find_rule_mut(&mut self, name: &str) -> Option<&mut PcbRule>
Find a rule by name mutably.
Sourcepub fn iter_components(&self) -> impl Iterator<Item = &PcbDocComponent>
pub fn iter_components(&self) -> impl Iterator<Item = &PcbDocComponent>
Iterate over components.
Sourcepub fn iter_primitives(&self) -> impl Iterator<Item = &PcbRecord>
pub fn iter_primitives(&self) -> impl Iterator<Item = &PcbRecord>
Iterate over primitives.
Sourcepub fn track_count(&self) -> usize
pub fn track_count(&self) -> usize
Count tracks.
Sourcepub fn find_component(&self, designator: &str) -> Option<&PcbDocComponent>
pub fn find_component(&self, designator: &str) -> Option<&PcbDocComponent>
Find a component by designator.
Sourcepub fn find_component_mut(
&mut self,
designator: &str,
) -> Option<&mut PcbDocComponent>
pub fn find_component_mut( &mut self, designator: &str, ) -> Option<&mut PcbDocComponent>
Find a component by designator mutably.
Sourcepub fn iter_components_mut(
&mut self,
) -> impl Iterator<Item = &mut PcbDocComponent>
pub fn iter_components_mut( &mut self, ) -> impl Iterator<Item = &mut PcbDocComponent>
Iterate over components mutably.
Sourcepub fn save_with_components<P: AsRef<Path>>(&self, path: P) -> Result<()>
pub fn save_with_components<P: AsRef<Path>>(&self, path: P) -> Result<()>
Save with component changes.
Sourcepub fn save_all_to_file<P: AsRef<Path>>(&self, path: P) -> Result<()>
pub fn save_all_to_file<P: AsRef<Path>>(&self, path: P) -> Result<()>
Save all primitives to a file path.
This comprehensive save method writes all primitive types:
- Tracks
- Vias
- Arcs
- Fills
- Regions
- Polygons
- Components
- Rules
Sourcepub fn fill_count(&self) -> usize
pub fn fill_count(&self) -> usize
Count fills.
Sourcepub fn region_count(&self) -> usize
pub fn region_count(&self) -> usize
Count regions.
Sourcepub fn polygon_count(&self) -> usize
pub fn polygon_count(&self) -> usize
Count polygons.
Sourcepub fn text_count(&self) -> usize
pub fn text_count(&self) -> usize
Count text elements.
Sourcepub fn add_region(&mut self, region: PcbRegion)
pub fn add_region(&mut self, region: PcbRegion)
Add a region.
Sourcepub fn add_polygon(&mut self, polygon: PcbPolygon)
pub fn add_polygon(&mut self, polygon: PcbPolygon)
Add a polygon.
Sourcepub fn remove_primitive(&mut self, index: usize) -> Option<PcbRecord>
pub fn remove_primitive(&mut self, index: usize) -> Option<PcbRecord>
Remove primitive at index.
Sourcepub fn get_primitive(&self, index: usize) -> Option<&PcbRecord>
pub fn get_primitive(&self, index: usize) -> Option<&PcbRecord>
Get primitive at index.
Sourcepub fn get_primitive_mut(&mut self, index: usize) -> Option<&mut PcbRecord>
pub fn get_primitive_mut(&mut self, index: usize) -> Option<&mut PcbRecord>
Get mutable primitive at index.
Sourcepub fn iter_tracks(&self) -> impl Iterator<Item = &PcbTrack>
pub fn iter_tracks(&self) -> impl Iterator<Item = &PcbTrack>
Iterate over tracks.
Sourcepub fn iter_fills(&self) -> impl Iterator<Item = &PcbFill>
pub fn iter_fills(&self) -> impl Iterator<Item = &PcbFill>
Iterate over fills.
Sourcepub fn iter_regions(&self) -> impl Iterator<Item = &PcbRegion>
pub fn iter_regions(&self) -> impl Iterator<Item = &PcbRegion>
Iterate over regions.
Sourcepub fn iter_polygons(&self) -> impl Iterator<Item = &PcbPolygon>
pub fn iter_polygons(&self) -> impl Iterator<Item = &PcbPolygon>
Iterate over polygons.
Sourcepub fn iter_texts(&self) -> impl Iterator<Item = &PcbText>
pub fn iter_texts(&self) -> impl Iterator<Item = &PcbText>
Iterate over texts.
Trait Implementations§
Source§impl DumpTree for PcbDoc
impl DumpTree for PcbDoc
Source§fn dump(&self, tree: &mut TreeBuilder)
fn dump(&self, tree: &mut TreeBuilder)
Source§fn dump_to_string(&self) -> String
fn dump_to_string(&self) -> String
Source§fn dump_to_string_with_options(&self, options: DumpOptions) -> String
fn dump_to_string_with_options(&self, options: DumpOptions) -> String
Auto Trait Implementations§
impl Freeze for PcbDoc
impl RefUnwindSafe for PcbDoc
impl Send for PcbDoc
impl Sync for PcbDoc
impl Unpin for PcbDoc
impl UnwindSafe for PcbDoc
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more