Skip to main content

PcbDoc

Struct PcbDoc 

Source
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: ParameterCollection

Board 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

Source

pub fn open<R: Read + Seek>(reader: R) -> Result<Self>

Open and read a PcbDoc file.

Source

pub fn open_file<P: AsRef<Path>>(path: P) -> Result<Self>

Open and read a PcbDoc file from a path.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn component_count(&self) -> usize

Get the number of components.

Source

pub fn primitive_count(&self) -> usize

Get the number of primitives.

Source

pub fn net_count(&self) -> usize

Get the number of nets.

Source

pub fn rule_count(&self) -> usize

Get the number of design rules.

Source

pub fn iter_rules(&self) -> impl Iterator<Item = &PcbRule>

Iterate over design rules.

Source

pub fn iter_rules_mut(&mut self) -> impl Iterator<Item = &mut PcbRule>

Iterate over design rules mutably.

Source

pub fn add_rule(&mut self, rule: PcbRule)

Add a design rule.

Source

pub fn find_rule(&self, name: &str) -> Option<&PcbRule>

Find a rule by name.

Source

pub fn find_rule_mut(&mut self, name: &str) -> Option<&mut PcbRule>

Find a rule by name mutably.

Source

pub fn iter_components(&self) -> impl Iterator<Item = &PcbDocComponent>

Iterate over components.

Source

pub fn iter_primitives(&self) -> impl Iterator<Item = &PcbRecord>

Iterate over primitives.

Source

pub fn track_count(&self) -> usize

Count tracks.

Source

pub fn via_count(&self) -> usize

Count vias.

Source

pub fn pad_count(&self) -> usize

Count pads (from components).

Source

pub fn find_component(&self, designator: &str) -> Option<&PcbDocComponent>

Find a component by designator.

Source

pub fn find_component_mut( &mut self, designator: &str, ) -> Option<&mut PcbDocComponent>

Find a component by designator mutably.

Source

pub fn iter_components_mut( &mut self, ) -> impl Iterator<Item = &mut PcbDocComponent>

Iterate over components mutably.

Source

pub fn save_with_components<P: AsRef<Path>>(&self, path: P) -> Result<()>

Save with component changes.

Source

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
Source

pub fn arc_count(&self) -> usize

Count arcs.

Source

pub fn fill_count(&self) -> usize

Count fills.

Source

pub fn region_count(&self) -> usize

Count regions.

Source

pub fn polygon_count(&self) -> usize

Count polygons.

Source

pub fn text_count(&self) -> usize

Count text elements.

Source

pub fn add_track(&mut self, track: PcbTrack)

Add a track.

Source

pub fn add_via(&mut self, via: PcbVia)

Add a via.

Source

pub fn add_arc(&mut self, arc: PcbArc)

Add an arc.

Source

pub fn add_fill(&mut self, fill: PcbFill)

Add a fill.

Source

pub fn add_region(&mut self, region: PcbRegion)

Add a region.

Source

pub fn add_polygon(&mut self, polygon: PcbPolygon)

Add a polygon.

Source

pub fn remove_primitive(&mut self, index: usize) -> Option<PcbRecord>

Remove primitive at index.

Source

pub fn get_primitive(&self, index: usize) -> Option<&PcbRecord>

Get primitive at index.

Source

pub fn get_primitive_mut(&mut self, index: usize) -> Option<&mut PcbRecord>

Get mutable primitive at index.

Source

pub fn iter_tracks(&self) -> impl Iterator<Item = &PcbTrack>

Iterate over tracks.

Source

pub fn iter_vias(&self) -> impl Iterator<Item = &PcbVia>

Iterate over vias.

Source

pub fn iter_arcs(&self) -> impl Iterator<Item = &PcbArc>

Iterate over arcs.

Source

pub fn iter_fills(&self) -> impl Iterator<Item = &PcbFill>

Iterate over fills.

Source

pub fn iter_regions(&self) -> impl Iterator<Item = &PcbRegion>

Iterate over regions.

Source

pub fn iter_polygons(&self) -> impl Iterator<Item = &PcbPolygon>

Iterate over polygons.

Source

pub fn iter_texts(&self) -> impl Iterator<Item = &PcbText>

Iterate over texts.

Source

pub fn add_text(&mut self, text: PcbText)

Add a text annotation.

Trait Implementations§

Source§

impl Debug for PcbDoc

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PcbDoc

Source§

fn default() -> PcbDoc

Returns the “default value” for a type. Read more
Source§

impl DumpTree for PcbDoc

Source§

fn dump(&self, tree: &mut TreeBuilder)

Dump this item to the tree builder.
Source§

fn dump_to_string(&self) -> String

Convenience method to dump to a string.
Source§

fn dump_to_string_with_options(&self, options: DumpOptions) -> String

Convenience method to dump to a string with options.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool