Skip to main content

FootprintFile

Struct FootprintFile 

Source
pub struct FootprintFile;

Implementations§

Source§

impl FootprintFile

Source

pub fn read<P: AsRef<Path>>(path: P) -> Result<FootprintDocument, Error>

Examples found in repository?
examples/footprint_roundtrip.rs (line 15)
10fn main() -> Result<(), String> {
11    let mut args = env::args().skip(1);
12    let in_path = args.next().map(PathBuf::from).ok_or_else(usage)?;
13    let out_path = args.next().map(PathBuf::from).ok_or_else(usage)?;
14
15    let mut doc = FootprintFile::read(&in_path).map_err(|e| e.to_string())?;
16    doc.set_generator("kiutils")
17        .set_generator_version("roundtrip-demo")
18        .upsert_property("EditedBy", "kiutils_kicad/examples/footprint_roundtrip.rs");
19
20    doc.write(&out_path).map_err(|e| e.to_string())?;
21
22    let reread = FootprintFile::read(&out_path).map_err(|e| e.to_string())?;
23    println!("input: {}", in_path.display());
24    println!("output: {}", out_path.display());
25    println!("lib_id: {:?}", reread.ast().lib_id);
26    println!("properties: {}", reread.ast().property_count);
27    println!("unknown_nodes: {}", reread.ast().unknown_nodes.len());
28    println!("diagnostics: {}", reread.diagnostics().len());
29
30    Ok(())
31}
More examples
Hide additional examples
examples/read_all.rs (line 17)
8fn main() -> Result<(), Box<dyn std::error::Error>> {
9    let base = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
10        .join("examples")
11        .join("data");
12
13    let pcb = PcbFile::read(base.join("sample.kicad_pcb"))?;
14    println!("pcb version: {:?}", pcb.ast().version);
15    println!("pcb unknown nodes: {}", pcb.ast().unknown_nodes.len());
16
17    let footprint = FootprintFile::read(base.join("sample.kicad_mod"))?;
18    println!("footprint version: {:?}", footprint.ast().version);
19
20    let schematic = SchematicFile::read(base.join("sample.kicad_sch"))?;
21    println!("schematic version: {:?}", schematic.ast().version);
22    println!(
23        "schematic unknown nodes: {}",
24        schematic.ast().unknown_nodes.len()
25    );
26
27    let table = FpLibTableFile::read(base.join("fp-lib-table"))?;
28    println!("fp libs: {}", table.ast().library_count);
29
30    let sym_table = SymLibTableFile::read(base.join("sym-lib-table"))?;
31    println!("sym libs: {}", sym_table.ast().library_count);
32
33    let dru = DesignRulesFile::read(base.join("sample.kicad_dru"))?;
34    println!("rules: {}", dru.ast().rule_count);
35    println!("rule constraints: {}", dru.ast().total_constraint_count);
36
37    let project = ProjectFile::read(base.join("sample.kicad_pro"))?;
38    println!("project meta version: {:?}", project.ast().meta_version);
39
40    let worksheet = WorksheetFile::read(base.join("sample.kicad_wks"))?;
41    println!("worksheet version: {:?}", worksheet.ast().version);
42    println!("worksheet tbtext count: {}", worksheet.ast().tbtext_count);
43
44    pcb.write_mode("/tmp/out.kicad_pcb", WriteMode::Lossless)?;
45    Ok(())
46}

Auto Trait Implementations§

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, 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.