altium 0.2.1

A library for processing Altium file types
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
//! Records that are stored.
//!
//! A component in a schematic lib typically look something like the following
//! (line breaks and indents added only for clarity)
//!
//! ```text
//! |RECORD=1
//!     |LibReference=CombinedPins
//!     |ComponentDescription=Single passive pin at (0,0) with 0 rotation
//!     |PartCount=2|DisplayModeCount=1
//!     |IndexInSheet=-1
//!     |OwnerPartId=-1
//!     |CurrentPartId=1
//!     |LibraryPath=*
//!     |SourceLibraryName=*
//!     |SheetPartFileName=*
//!     |TargetFileName=*
//!     |UniqueID=OXKUDQCE
//!     |AreaColor=11599871
//!     |Color=128
//!     |PartIDLocked=T
//!     |AllPinCount=1
//!     [pin binary data]
//! |RECORD=34
//!     |IndexInSheet=-1
//!     |OwnerPartId=-1
//!     |Location.X=-5
//!     |Location.Y=5
//!     |Color=8388608
//!     |FontID=2
//!     |Text=Pin?
//!     |Name=Designator
//!     |ReadOnlyState=1
//!     |UniqueID=VWHBCSOI
//! |RECORD=41
//!     |IndexInSheet=-1
//!     |OwnerPartId=-1
//!     |Location.X=-5
//!     |Location.Y=-15
//!     |Color=8388608
//!     |FontID=2
//!     |IsHidden=T
//!     |Name=Comment
//!     |UniqueID=HEUKMELO
//! ```
//!
//! Notably, it's just a bunch of "records" (with meaningful number identifiers)
//! thrown together. Anything that implements `FromRecord` can take the contents
//! of one of these records (an indented section) and parse it.
//!
//! We provide a derive macro for `FromRecord`, so most types in this module
//! don't need to do anything special.
mod draw;
mod parse;

use std::str;

use altium_macros::FromRecord;
pub use draw::SchDrawCtx;
pub(super) use parse::parse_all_records;

use super::params::Justification;
use super::pin::SchPin;
use crate::common::{Location, LocationFract, ReadOnlyState, UniqueId};
use crate::error::{AddContext, TruncBuf};
use crate::font::FontCollection;
use crate::Error;
use crate::{
    common::Rgb,
    parse::{FromRecord, ParseUtf8},
    ErrorKind,
};

/// A representation of a record in a schematic library or document.
///
/// Altium represents schematic formats as a collection of records. Some have a visual
/// representation whereas others are just metadata. Each variant represents a record
/// type.
#[non_exhaustive]
#[derive(Clone, Debug, PartialEq)]
pub enum SchRecord {
    Undefined,
    MetaData(Box<MetaData>),
    Pin(SchPin),
    IeeeSymbol(IeeeSymbol),
    Label(Label),
    Bezier(Bezier),
    PolyLine(PolyLine),
    Polygon(Polygon),
    Ellipse(Ellipse),
    Piechart(Piechart),
    RectangleRounded(RectangleRounded),
    ElipticalArc(ElipticalArc),
    Arc(Arc),
    Line(Line),
    Rectangle(Rectangle),
    SheetSymbol(SheetSymbol),
    SheetEntry(SheetEntry),
    PowerPort(PowerPort),
    Port(Port),
    NoErc(NoErc),
    NetLabel(NetLabel),
    Bus(Bus),
    Wire(Wire),
    TextFrame(TextFrame),
    Junction(Junction),
    Image(Image),
    Sheet(Sheet),
    SheetName(SheetName),
    FileName(FileName),
    Designator(Designator),
    BusEntry(BusEntry),
    Template(Template),
    Parameter(Parameter),
    ImplementationList(ImplementationList),
    Implementation(Implementation),
    ImplementationChild1(ImplementationChild1),
    ImplementationChild2(ImplementationChild2),
}

/// Try all known record types (excludes binary pins)
pub fn parse_any_record(buf: &[u8]) -> Result<SchRecord, Error> {
    let buf = buf.strip_prefix(b"|RECORD=").unwrap_or_else(|| {
        let tb = TruncBuf::new(buf);
        panic!("no record prefix in {tb} ({})", tb.as_str());
    });
    let num_chars = buf.iter().take_while(|ch| ch.is_ascii_digit()).count();
    let record_id_str = str::from_utf8(&buf[..num_chars]).unwrap();
    let record_id: u32 = record_id_str
        .parse()
        .map_err(|e| ErrorKind::ExpectedInt(record_id_str.into(), e))
        .context("error in parse_any_record")?;
    let to_parse = &buf[num_chars..];

    // Try parsing all our types, they will just skip to the next one if the
    // record ID doesn't match
    MetaData::parse_if_matches(record_id, to_parse)
        .or_else(|| SchPin::parse_if_matches(record_id, to_parse))
        .or_else(|| IeeeSymbol::parse_if_matches(record_id, to_parse))
        .or_else(|| Label::parse_if_matches(record_id, to_parse))
        .or_else(|| Bezier::parse_if_matches(record_id, to_parse))
        .or_else(|| PolyLine::parse_if_matches(record_id, to_parse))
        .or_else(|| Polygon::parse_if_matches(record_id, to_parse))
        .or_else(|| Ellipse::parse_if_matches(record_id, to_parse))
        .or_else(|| Piechart::parse_if_matches(record_id, to_parse))
        .or_else(|| RectangleRounded::parse_if_matches(record_id, to_parse))
        .or_else(|| ElipticalArc::parse_if_matches(record_id, to_parse))
        .or_else(|| Arc::parse_if_matches(record_id, to_parse))
        .or_else(|| Line::parse_if_matches(record_id, to_parse))
        .or_else(|| Rectangle::parse_if_matches(record_id, to_parse))
        .or_else(|| SheetSymbol::parse_if_matches(record_id, to_parse))
        .or_else(|| SheetEntry::parse_if_matches(record_id, to_parse))
        .or_else(|| PowerPort::parse_if_matches(record_id, to_parse))
        .or_else(|| Port::parse_if_matches(record_id, to_parse))
        .or_else(|| NoErc::parse_if_matches(record_id, to_parse))
        .or_else(|| NetLabel::parse_if_matches(record_id, to_parse))
        .or_else(|| Bus::parse_if_matches(record_id, to_parse))
        .or_else(|| Wire::parse_if_matches(record_id, to_parse))
        .or_else(|| TextFrame::parse_if_matches(record_id, to_parse))
        .or_else(|| Junction::parse_if_matches(record_id, to_parse))
        .or_else(|| Image::parse_if_matches(record_id, to_parse))
        .or_else(|| Sheet::parse_if_matches(record_id, to_parse))
        .or_else(|| SheetName::parse_if_matches(record_id, to_parse))
        .or_else(|| FileName::parse_if_matches(record_id, to_parse))
        .or_else(|| Designator::parse_if_matches(record_id, to_parse))
        .or_else(|| BusEntry::parse_if_matches(record_id, to_parse))
        .or_else(|| Template::parse_if_matches(record_id, to_parse))
        .or_else(|| Parameter::parse_if_matches(record_id, to_parse))
        .or_else(|| ImplementationList::parse_if_matches(record_id, to_parse))
        .or_else(|| Implementation::parse_if_matches(record_id, to_parse))
        .or_else(|| ImplementationChild1::parse_if_matches(record_id, to_parse))
        .or_else(|| ImplementationChild2::parse_if_matches(record_id, to_parse))
        .unwrap_or_else(|| {
            log::error!("unknown record id {record_id}");
            Ok(SchRecord::Undefined)
        })
}

/// Component metadata (AKA "Component")
#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, FromRecord)]
#[from_record(id = 1, use_box = true)]
pub struct MetaData {
    all_pin_count: u32,
    pub area_color: Rgb,
    pub color: Rgb,
    current_part_id: u8,
    database_table_name: Box<str>,
    #[from_record(rename = b"ComponentDescription")]
    pub(crate) description: Option<Box<str>>,
    /// Alternative display modes
    display_mode_count: u8,
    index_in_sheet: i16,
    library_path: Box<str>,
    #[from_record(rename = b"LibReference")]
    libref: Box<str>,
    owner_part_id: i8,
    /// Number of parts
    part_count: u8,
    part_id_locked: bool,
    not_use_db_table_name: bool,
    orientation: i32,
    sheet_part_file_name: Box<str>,
    design_item_id: Box<str>,
    source_library_name: Box<str>,
    target_file_name: Box<str>,
    location: Location,
    unique_id: UniqueId,
}

#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, FromRecord)]
#[from_record(id = 3)]
pub struct IeeeSymbol {
    is_not_accessible: bool,
    pub location: Location,
    owner_index: u8,
    owner_part_id: i8,
}

#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, FromRecord)]
#[from_record(id = 4)]
pub struct Label {
    pub color: Rgb,
    font_id: u16,
    index_in_sheet: i16,
    is_not_accessible: bool,
    is_mirrored: bool,
    pub location: Location,
    owner_index: u8,
    owner_part_id: i8,
    text: Box<str>,
    pub unique_id: UniqueId,
    pub justification: Justification,
}

#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, FromRecord)]
#[from_record(id = 5)]
pub struct Bezier {
    color: Rgb,
    index_in_sheet: i16,
    is_not_accessible: bool,
    line_width: u16,
    #[from_record(array = true, count = b"LocationCount", map = (X -> x, Y -> y))]
    pub locations: Vec<Location>,
    owner_index: u8,
    owner_part_id: i8,
    owner_part_display_mode: i8,
    pub unique_id: UniqueId,
}

#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, FromRecord)]
#[from_record(id = 6)]
pub struct PolyLine {
    owner_index: u8,
    owner_part_id: i8,
    is_not_accessible: bool,
    index_in_sheet: i16,
    line_width: u16,
    pub color: Rgb,
    #[from_record(array = true, count = b"LocationCount", map = (X -> x, Y -> y))]
    pub locations: Vec<Location>,
    pub unique_id: UniqueId,
}

#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, FromRecord)]
#[from_record(id = 7)]
pub struct Polygon {
    pub area_color: Rgb,
    pub color: Rgb,
    index_in_sheet: i16,
    is_not_accessible: bool,
    is_solid: bool,
    line_width: u16,
    #[from_record(array = true, count = b"LocationCount", map = (X -> x, Y -> y))]
    pub locations: Vec<Location>,
    owner_index: u8,
    owner_part_id: i8,
    owner_part_display_mode: i8,
    pub unique_id: UniqueId,
}

#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, FromRecord)]
#[from_record(id = 8)]
pub struct Ellipse {
    pub area_color: Rgb,
    pub color: Rgb,
    index_in_sheet: i16,
    is_not_accessible: bool,
    is_solid: bool,
    line_width: u16,
    pub location: Location,
    owner_index: u8,
    owner_part_id: i8,
    owner_part_display_mode: i8,
    radius: i32,
    secondary_radius: i32,
    pub unique_id: UniqueId,
}

#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, FromRecord)]
#[from_record(id = 9)]
pub struct Piechart {
    owner_index: u8,
    owner_part_id: i8,
}

#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, FromRecord)]
#[from_record(id = 10)]
pub struct RectangleRounded {
    pub area_color: Rgb,
    pub color: Rgb,
    corner: Location,
    corner_x_radius: i32,
    corner_y_radius: i32,
    index_in_sheet: i16,
    is_not_accessible: bool,
    is_solid: bool,
    line_width: u16,
    location: Location,
    owner_index: u8,
    owner_part_id: i8,
    owner_part_display_mode: i8,
    transparent: bool,
    pub unique_id: UniqueId,
}

#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, FromRecord)]
#[from_record(id = 11)]
pub struct ElipticalArc {
    owner_index: u8,
    owner_part_id: i8,
    is_not_accessible: bool,
    index_in_sheet: i16,
    location: LocationFract,
    radius: i8,
    radius_frac: i32,
    secondary_radius: i8,
    secondary_radius_frac: i32,
    line_width: i8,
    start_angle: f32,
    end_angle: f32,
    pub color: Rgb,
    pub unique_id: UniqueId,
}

#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, FromRecord)]
#[from_record(id = 12)]
pub struct Arc {
    owner_index: u8,
    owner_part_id: i8,
    is_not_accessible: bool,
    index_in_sheet: i16,
    pub location: Location,
    radius: i8,
    radius_frac: i32,
    secondary_radius: i8,
    secondary_radius_frac: i32,
    line_width: i8,
    start_angle: f32,
    end_angle: f32,
    pub color: Rgb,
    pub unique_id: UniqueId,
}

#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, FromRecord)]
#[from_record(id = 13)]
pub struct Line {
    pub color: Rgb,
    corner_x: i32,
    corner_y: i32,
    index_in_sheet: i16,
    is_not_accessible: bool,
    is_solid: bool,
    line_width: u16,
    location_count: u16,
    location_x: i32,
    location_y: i32,
    owner_index: u8,
    owner_part_id: i8,
    owner_part_display_mode: i8,
    pub unique_id: UniqueId,
}

#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, FromRecord)]
#[from_record(id = 14)]
pub struct Rectangle {
    pub area_color: Rgb,
    pub color: Rgb,
    /// Top right corner
    pub corner: Location,
    index_in_sheet: i16,
    is_not_accessible: bool,
    pub is_solid: bool,
    line_width: u16,
    /// Bottom left corner
    pub location: Location,
    owner_index: u8,
    owner_part_id: i8,
    owner_part_display_mode: i8,
    pub transparent: bool,
    pub unique_id: UniqueId,
}

#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, FromRecord)]
#[from_record(id = 15)]
pub struct SheetSymbol {
    owner_index: u8,
    owner_part_id: i8,
    index_in_sheet: i16,
    line_width: u16,
    pub color: Rgb,
    pub area_color: Rgb,
    is_solid: bool,
    pub location: Location,
    symbol_type: Box<str>,
    show_net_name: bool,
    x_size: i32,
    y_size: i32,
    orientation: i32,
    font_id: u16,
    text: Box<str>,
    pub unique_id: UniqueId,
}

#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, FromRecord)]
#[from_record(id = 16)]
pub struct SheetEntry {
    owner_index: u8,
    owner_part_id: i8,
    index_in_sheet: i16,
    pub text_color: Rgb,
    pub area_color: Rgb,
    text_font_id: u16,
    text_style: Box<str>,
    name: Box<str>,
    pub unique_id: UniqueId,
    arrow_kind: Box<str>,
    distance_from_top: i32,
    color: Rgb,
    #[from_record(rename = b"IOType")]
    io_type: i32,
    side: i32,
}

#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, FromRecord)]
#[from_record(id = 17)]
pub struct PowerPort {
    owner_index: u8,
    owner_part_id: i8,
    is_cross_sheet_connector: bool,
    index_in_sheet: i16,
    style: i16,
    show_net_name: bool,
    pub location: Location,
    orientation: i32,
    font_id: u16,
    text: Box<str>,
    pub unique_id: UniqueId,
    pub color: Rgb,
}

#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, FromRecord)]
#[from_record(id = 18)]
pub struct Port {
    alignment: u16,
    pub area_color: Rgb,
    border_width: i32,
    pub color: Rgb,
    font_id: u16,
    height: i32,
    width: i32,
    index_in_sheet: i16,
    #[from_record(rename = b"IOType")]
    io_type: u16,
    pub location: Location,
    name: Box<str>,
    owner_index: u8,
    owner_part_id: i8,
    pub text_color: Rgb,
    pub unique_id: UniqueId,
}

#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, FromRecord)]
#[from_record(id = 22)]
pub struct NoErc {
    owner_index: u8,
    owner_part_id: i8,
    index_in_sheet: i16,
    orientation: i16,
    symbol: Box<str>,
    is_active: bool,
    suppress_all: bool,
    pub location: Location,
    pub color: Rgb,
    pub unique_id: UniqueId,
}

#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, FromRecord)]
#[from_record(id = 25)]
pub struct NetLabel {
    owner_index: u8,
    owner_part_id: i8,
    index_in_sheet: i16,
    pub location: Location,
    pub color: Rgb,
    font_id: u16,
    text: Box<str>,
    pub unique_id: UniqueId,
}

#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, FromRecord)]
#[from_record(id = 26)]
pub struct Bus {
    owner_index: u8,
    owner_part_id: i8,
    index_in_sheet: i16,
    line_width: u16,
    pub color: Rgb,
    #[from_record(array = true, count = b"LocationCount", map = (X -> x, Y -> y))]
    pub locations: Vec<Location>,
    pub unique_id: UniqueId,
}

#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, FromRecord)]
#[from_record(id = 27)]
pub struct Wire {
    owner_index: u8,
    owner_part_id: i8,
    line_width: u16,
    pub color: Rgb,
    #[from_record(array = true, count = b"LocationCount", map = (X -> x, Y -> y))]
    pub locations: Vec<Location>,
    index_in_sheet: i16,
    pub unique_id: UniqueId,
}

#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, FromRecord)]
#[from_record(id = 28)]
pub struct TextFrame {
    location: LocationFract,
    corner: LocationFract,
    pub area_color: Rgb,
    owner_index: u8,
    owner_part_id: i8,
    font_id: u16,
    alignment: u16,
    word_wrap: bool,
    pub text: Box<str>,
    index_in_sheet: i16,
    clip_to_rect: bool,
    pub unique_id: UniqueId,
}

#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, FromRecord)]
#[from_record(id = 29)]
pub struct Junction {
    owner_index: u8,
    owner_part_id: i8,
}

#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, FromRecord)]
#[from_record(id = 30)]
pub struct Image {
    owner_index: u8,
    owner_part_id: i8,
    is_not_accessible: bool,
    index_in_sheet: i16,
    pub location: Location,
    pub corner: Location,
    keep_aspect: bool,
    embed_image: bool,
    file_name: Box<str>,
    pub unique_id: UniqueId,
    corner_x_frac: i32,
    corner_y_frac: i32,
}

#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, FromRecord)]
#[from_record(id = 31)]
pub struct Sheet {
    owner_index: u8,
    owner_part_id: i8,
    snap_grid_size: i32,
    snap_grid_on: bool,
    visible_grid_on: bool,
    visible_grid_size: i32,
    custom_x: i32,
    custom_y: i32,
    custom_x_zones: u16,
    custom_y_zones: u16,
    custom_margin_width: u16,
    hot_spot_grid_on: bool,
    hot_spot_grid_size: i32,
    system_font: u16,
    #[from_record(array = true, count = b"FontIdCount", map = (FontName -> name, Size -> size))]
    pub(super) fonts: FontCollection,
    border_on: bool,
    sheet_number_space_size: i32,
    pub area_color: Rgb,
    // FIXME: make this an enum
    #[from_record(rename = b"Display_Unit")]
    display_unit: u16,
    #[from_record(rename = b"UseMBCS")]
    use_mbcs: bool,
    #[from_record(rename = b"IsBOC")]
    is_boc: bool,
    // FIXME: seems to be base64
    file_version_info: Box<str>,
}

#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, FromRecord)]
#[from_record(id = 32)]
pub struct SheetName {
    owner_index: u8,
    owner_part_id: i8,
    index_in_sheet: i16,
    pub location: Location,
    pub color: Rgb,
    font_id: u16,
    pub text: Box<str>,
    pub unique_id: UniqueId,
}

#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, FromRecord)]
#[from_record(id = 33)]
pub struct FileName {
    owner_index: u8,
    owner_part_id: i8,
    index_in_sheet: i16,
    pub location: Location,
    pub color: Rgb,
    font_id: u16,
    pub text: Box<str>,
    pub unique_id: UniqueId,
}

#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, FromRecord)]
#[from_record(id = 34)]
pub struct Designator {
    owner_index: u8,
    owner_part_id: i8,
    pub location: Location,
    pub color: Rgb,
    #[from_record(rename = b"FontID")]
    font_id: u16,
    pub unique_id: UniqueId,
    pub name: Box<str>,
    index_in_sheet: i16,
    pub text: Box<str>,
    read_only_state: ReadOnlyState,
}

#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, FromRecord)]
#[from_record(id = 37)]
pub struct BusEntry {
    owner_index: u8,
    owner_part_id: i8,
}

#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, FromRecord)]
#[from_record(id = 39)]
pub struct Template {
    owner_index: u8,
    owner_part_id: i8,
    is_not_accessible: bool,
    file_name: Box<str>,
}

#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, FromRecord)]
#[from_record(id = 41)]
pub struct Parameter {
    owner_index: u8,
    owner_part_id: i8,
    pub location: Location,
    index_in_sheet: i16,
    pub color: Rgb,
    font_id: u16,
    pub unique_id: UniqueId,
    read_only_state: i8,
    pub name: Box<str>,
    is_hidden: bool,
    pub text: Box<str>,
}

#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, FromRecord)]
#[from_record(id = 44)]
pub struct ImplementationList {
    owner_index: u8,
    owner_part_id: i8,
}

/// Things like models, including footprints
#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, FromRecord)]
#[from_record(id = 45)]
pub struct Implementation {
    owner_index: u8,
    owner_part_id: i8,
    use_component_library: bool,
    model_name: Box<str>,
    model_type: Box<str>,
    datafile_count: u16,
    model_datafile_entity0: Box<str>,
    model_datafile_kind0: Box<str>,
    is_current: bool,
    datalinks_locked: bool,
    database_datalinks_locked: bool,
    pub unique_id: UniqueId,
    index_in_sheet: i16,
}

#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, FromRecord)]
#[from_record(id = 46)]
pub struct ImplementationChild1 {
    owner_index: u8,
    owner_part_id: i8,
}

#[non_exhaustive]
#[derive(Clone, Debug, Default, PartialEq, FromRecord)]
#[from_record(id = 48)]
pub struct ImplementationChild2 {
    owner_index: u8,
    owner_part_id: i8,
}