pub struct Audit {
pub reading: Reading,
pub systems: Vec<SystemAudit>,
pub score: f64,
pub findings: BTreeMap<String, usize>,
pub pages: Vec<[f64; 2]>,
}Expand description
A PDF’s reading and what is suspect in it.
Fields§
§reading: Reading§systems: Vec<SystemAudit>§score: f64The systems’ scores, summed.
findings: BTreeMap<String, usize>Each kind of finding and how many bars or systems have it.
pages: Vec<[f64; 2]>The pages’ sizes, in points.
Implementations§
Source§impl Audit
impl Audit
Sourcepub fn to_json(&self) -> String
pub fn to_json(&self) -> String
The audit as JSON, the reading’s .fmn and MusicXML left out: the PDF’s score, its
bars and systems counted, the findings by kind, the marks printed and written by kind,
and every system (its page, frame, score, reasons, and its bars with theirs).
Examples found in repository?
examples/audit.rs (line 22)
7fn main() {
8 let a: Vec<String> = std::env::args().collect();
9 if a.len() < 2 {
10 eprintln!("usage: audit SCORE.pdf [OUT.json [OUT.musicxml [OUT.fmn]]]");
11 std::process::exit(2);
12 }
13 let bytes = std::fs::read(&a[1]).expect("reading the PDF");
14 let audit = match fm_vector::audit_pdf(&bytes) {
15 Ok(x) => x,
16 Err(e) => {
17 println!("refused: {}", e.why.replace('\n', " "));
18 std::process::exit(1);
19 }
20 };
21 if let Some(out) = a.get(2) {
22 std::fs::write(out, audit.to_json()).expect("writing the JSON");
23 }
24 if let Some(out) = a.get(3) {
25 std::fs::write(out, &audit.reading.musicxml).expect("writing the MusicXML");
26 }
27 if let Some(out) = a.get(4) {
28 std::fs::write(out, &audit.reading.fmn).expect("writing the .fmn");
29 }
30 let bars: usize = audit.systems.iter().map(|s| s.bars.len()).sum();
31 let findings: Vec<String> = (audit.findings.iter())
32 .map(|(k, n)| format!("{k}={n}"))
33 .collect();
34 println!(
35 "audited\t{:.1}\t{} systems\t{bars} bars\t{} unread\t{}",
36 audit.score,
37 audit.systems.len(),
38 audit.reading.unread.len(),
39 findings.join("; ")
40 );
41 let mut worst: Vec<&fm_vector::SystemAudit> = audit.systems.iter().collect();
42 worst.sort_by(|x, y| y.score.total_cmp(&x.score));
43 for s in worst.iter().take(10).filter(|s| s.score > 0.0) {
44 let mut why = s.reasons.clone();
45 for b in &s.bars {
46 why.extend(b.reasons.iter().map(|r| format!("bar {}: {r}", b.bar)));
47 }
48 println!(
49 "system\t{}\tpage {}\t{:.1}\t{}",
50 s.system + 1,
51 s.page + 1,
52 s.score,
53 why.join("; ")
54 );
55 }
56}Trait Implementations§
Auto Trait Implementations§
impl Forget for Audit
impl Freeze for Auditwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<String>: Freeze,
PhantomData<Unread>: Freeze,
*const LeafNode<(i64, String), Seen> is !null: Freeze,
PhantomData<(Owned, LeafOrInternal)>: Freeze,
PhantomData<Box<((i64, String), Seen)>>: Freeze,
*const LeafNode<(i64, String), Place> is !null: Freeze,
PhantomData<Box<((i64, String), Place)>>: Freeze,
*const LeafNode<i64, usize> is !null: Freeze,
PhantomData<Box<(i64, usize)>>: Freeze,
PhantomData<NoteMark>: Freeze,
PhantomData<SystemAudit>: Freeze,
*const LeafNode<String, usize> is !null: Freeze,
PhantomData<Box<(String, usize)>>: Freeze,
PhantomData<[f64; 2]>: Freeze,
impl Move for Audit
impl RefUnwindSafe for Audit
impl Send for Auditwhere
RawVecInner: Send,
NodeRef<Owned, (i64, String), Seen, LeafOrInternal>: Send,
BoxRaw<((i64, String), Seen)>: Send,
NodeRef<Owned, (i64, String), Place, LeafOrInternal>: Send,
BoxRaw<((i64, String), Place)>: Send,
NodeRef<Owned, i64, usize, LeafOrInternal>: Send,
BoxRaw<(i64, usize)>: Send,
NodeRef<Owned, String, usize, LeafOrInternal>: Send,
BoxRaw<(String, usize)>: Send,
impl Sync for Auditwhere
RawVecInner: Sync,
NodeRef<Owned, (i64, String), Seen, LeafOrInternal>: Sync,
BoxRaw<((i64, String), Seen)>: Sync,
NodeRef<Owned, (i64, String), Place, LeafOrInternal>: Sync,
BoxRaw<((i64, String), Place)>: Sync,
NodeRef<Owned, i64, usize, LeafOrInternal>: Sync,
BoxRaw<(i64, usize)>: Sync,
NodeRef<Owned, String, usize, LeafOrInternal>: Sync,
BoxRaw<(String, usize)>: Sync,
impl Unpin for Auditwhere
*const u8 is !null: Unpin,
*const LeafNode<(i64, String), Seen> is !null: Unpin,
Box<((i64, String), Seen)>: Unpin,
*const LeafNode<(i64, String), Place> is !null: Unpin,
Box<((i64, String), Place)>: Unpin,
*const LeafNode<i64, usize> is !null: Unpin,
Box<(i64, usize)>: Unpin,
*const LeafNode<String, usize> is !null: Unpin,
Box<(String, usize)>: Unpin,
impl UnsafeUnpin for Auditwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
PhantomData<Unread>: UnsafeUnpin,
*const LeafNode<(i64, String), Seen> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<((i64, String), Seen)>>: UnsafeUnpin,
*const LeafNode<(i64, String), Place> is !null: UnsafeUnpin,
PhantomData<Box<((i64, String), Place)>>: UnsafeUnpin,
*const LeafNode<i64, usize> is !null: UnsafeUnpin,
PhantomData<Box<(i64, usize)>>: UnsafeUnpin,
PhantomData<NoteMark>: UnsafeUnpin,
PhantomData<SystemAudit>: UnsafeUnpin,
*const LeafNode<String, usize> is !null: UnsafeUnpin,
PhantomData<Box<(String, usize)>>: UnsafeUnpin,
PhantomData<[f64; 2]>: UnsafeUnpin,
impl UnwindSafe for Auditwhere
RawVecInner: UnwindSafe,
BTreeMap<(i64, String), Seen>: UnwindSafe,
BTreeMap<(i64, String), Place>: UnwindSafe,
BTreeMap<i64, usize>: UnwindSafe,
BTreeMap<String, usize>: UnwindSafe,
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
Mutably borrows from an owned value. Read more