style: cargo fmt

This commit is contained in:
Dylan M. Taylor
2026-10-24 02:22:36 +00:00
parent 89dc9f3906
commit 03b641275c
10 changed files with 19 additions and 26 deletions
+1 -3
View File
@@ -57,9 +57,7 @@ fn bdc_marks(doc: &Document, op: &pdfcraft_content::Op, props: &Dict) -> bool {
op.name(0) == Some(b"Artifact") op.name(0) == Some(b"Artifact")
|| match op.operands.get(1) { || match op.operands.get(1) {
Some(Object::Dict(d)) => d.contains(b"MCID"), Some(Object::Dict(d)) => d.contains(b"MCID"),
Some(Object::Name(n)) => { Some(Object::Name(n)) => props.get(n).map(|x| doc.resolve(x)).and_then(|x| x.as_dict().map(|d| d.contains(b"MCID"))).unwrap_or(false),
props.get(n).map(|x| doc.resolve(x)).and_then(|x| x.as_dict().map(|d| d.contains(b"MCID"))).unwrap_or(false)
}
_ => false, _ => false,
} }
} }
+1 -1
View File
@@ -6,8 +6,8 @@ use std::cell::Cell;
use pdfcraft_cos::{Dict, Document, ObjRef, Object, PdfString}; use pdfcraft_cos::{Dict, Document, ObjRef, Object, PdfString};
use super::{AddedText, GLYPHS_PER_FONT, GlyphError, GlyphOutline, LaidLine, Piece, ShapedCluster, ShapedScript, draw_laid_shaped};
use crate::EditError; use crate::EditError;
use super::{draw_laid_shaped, AddedText, GlyphError, GlyphOutline, LaidLine, Piece, ShapedCluster, ShapedScript, GLYPHS_PER_FONT};
/// Regression fingerprint for the small-item fixture: drawing bytes, font map and document /// Regression fingerprint for the small-item fixture: drawing bytes, font map and document
/// objects, with generated streams decoded so Flate backend selection cannot change the hash. /// objects, with generated streams decoded so Flate backend selection cannot change the hash.
+2 -3
View File
@@ -1,9 +1,8 @@
use pdfcraft_cos::{Dict, Document, Object, Stream}; use pdfcraft_cos::{Dict, Document, Object, Stream};
use super::{ use super::{
added, add_header_footer, add_watermark, contents, is_wrap_close, page_list, place_tagged, remove_marks, Context, EditError, HeaderFooter, ISOLATION_MAX_DEPTH, MarkKind, OLD_WRAP_CLOSE, WRAP_CLOSE, WRAP_OPEN, Watermark, add_header_footer,
stamp, stream_bytes, stream_tag, wrapper_role, Context, EditError, HeaderFooter, MarkKind, Watermark, add_watermark, added, contents, is_wrap_close, page_list, place_tagged, remove_marks, stamp, stream_bytes, stream_tag, wrapper_role,
ISOLATION_MAX_DEPTH, OLD_WRAP_CLOSE, WRAP_CLOSE, WRAP_OPEN,
}; };
fn fixture(parts: &[&[u8]]) -> Document { fn fixture(parts: &[&[u8]]) -> Document {
+3 -4
View File
@@ -5,10 +5,9 @@ use std::collections::HashMap;
use pdfcraft_cos::{Dict, Document, Object, PdfString}; use pdfcraft_cos::{Dict, Document, Object, PdfString};
use super::{ use super::{
coincident_ops, content_streams, needs_type3, no_japanese_font, page_dict, reveal_ops, rewritten_contents, BlockStyle, EditError, LineEdit, MAX_TYPE3_GLYPHS, Matrix, Metrics, Op, Pieces, RangeStyle, TextBlock, TextLine, coincident_ops, content_streams,
source_encodes, source_family, source_program, source_show, source_space, source_width, splice, type3_font, needs_type3, no_japanese_font, page_dict, reveal_ops, rewritten_contents, source_encodes, source_family, source_program, source_show,
union, BlockStyle, EditError, LineEdit, Matrix, Metrics, Op, Pieces, RangeStyle, TextBlock, TextLine, source_space, source_width, splice, type3_font, union,
MAX_TYPE3_GLYPHS,
}; };
fn same_plane(a: &TextLine, b: &TextLine) -> bool { fn same_plane(a: &TextLine, b: &TextLine) -> bool {
+2 -2
View File
@@ -4,8 +4,8 @@
//! that document has changed since. //! that document has changed since.
use super::{ use super::{
group_blocks, layout_draft, rewrite_block_from, text_lines, BlockStyle, Document, EditError, LineEdit, BlockStyle, Document, EditError, LineEdit, MAX_TYPE3_GLYPHS, TextBlock, TextEditLayout, TextLine, group_blocks, layout_draft, rewrite_block_from,
TextBlock, TextEditLayout, TextLine, MAX_TYPE3_GLYPHS, text_lines,
}; };
/// One paragraph being edited: the document as it was opened, and the page's lines then. /// One paragraph being edited: the document as it was opened, and the page's lines then.
+1 -2
View File
@@ -4,8 +4,7 @@ use std::sync::atomic::Ordering;
use pdfcraft_cos::{Algorithm, Dict, Document, NewEncryption, ObjRef, Object, SaveOptions, Stream, XrefEntry, write_full, write_incremental}; use pdfcraft_cos::{Algorithm, Dict, Document, NewEncryption, ObjRef, Object, SaveOptions, Stream, XrefEntry, write_full, write_incremental};
use super::{ use super::{
is_document_timestamp, list_cached, only_grew, DigestCache, DssEvidence, TrustStore, DISCOVERY_CACHE_LIMIT, DISCOVERY_CACHE_LIMIT, DigestCache, DssEvidence, MAX_DSS_BYTES, MAX_DSS_ENTRIES, TrustStore, is_document_timestamp, list_cached, only_grew,
MAX_DSS_BYTES, MAX_DSS_ENTRIES,
}; };
const STAMP: &str = "<< /Type /Sig /SubFilter /ETSI.RFC3161 /ByteRange [0 1 2 1] >>"; const STAMP: &str = "<< /Type /Sig /SubFilter /ETSI.RFC3161 /ByteRange [0 1 2 1] >>";
+3 -1
View File
@@ -43,7 +43,9 @@ fn store(tag: &str) -> RecoveryStore {
/// Snapshot files (the PDF and its sidecar), not the running instances' lock files. /// Snapshot files (the PDF and its sidecar), not the running instances' lock files.
fn files_in(s: &RecoveryStore) -> usize { fn files_in(s: &RecoveryStore) -> usize {
std::fs::read_dir(s.dir()).map(|d| d.flatten().filter(|e| e.path().extension().and_then(std::ffi::OsStr::to_str) != Some("lock")).count()).unwrap_or(0) std::fs::read_dir(s.dir())
.map(|d| d.flatten().filter(|e| e.path().extension().and_then(std::ffi::OsStr::to_str) != Some("lock")).count())
.unwrap_or(0)
} }
/// A session that edits a document, autosaves, and then "crashes" (is dropped). /// A session that edits a document, autosaves, and then "crashes" (is dropped).
+2 -5
View File
@@ -441,11 +441,8 @@ pub fn pattern_to_iso(text: &str, pattern: &str) -> Option<String> {
"yyyy" | "yy" | "mm" | "m" | "dd" | "d" => { "yyyy" | "yy" | "mm" | "m" | "dd" | "d" => {
// Digits up to the next literal (or a fixed width). // Digits up to the next literal (or a fixed width).
let fixed = matches!(t.as_str(), "yyyy" | "yy" | "mm" | "dd"); let fixed = matches!(t.as_str(), "yyyy" | "yy" | "mm" | "dd");
let width = if fixed { let width =
t.len() if fixed { t.len() } else { rest.chars().take_while(char::is_ascii_digit).count().min(if t == "d" || t == "m" { 2 } else { 4 }) };
} else {
rest.chars().take_while(char::is_ascii_digit).count().min(if t == "d" || t == "m" { 2 } else { 4 })
};
let digits: String = rest.chars().take(width).collect(); let digits: String = rest.chars().take(width).collect();
if digits.is_empty() || !digits.chars().all(char::is_ascii_digit) { if digits.is_empty() || !digits.chars().all(char::is_ascii_digit) {
return None; return None;
+2 -2
View File
@@ -15,8 +15,8 @@ use base64::Engine;
use crate::XfaError; use crate::XfaError;
use crate::data::{DataNode, data_date_letters, data_path, data_to_iso, date_letters, is_on, iso_to_pattern}; use crate::data::{DataNode, data_date_letters, data_path, data_to_iso, date_letters, is_on, iso_to_pattern};
use crate::model::{ use crate::model::{
Access, Area, Border, ChoiceList, Common, Draw, ExclGroup, Field, Font, HAlign, Layout, Margin, Node, Occur, Access, Area, Border, ChoiceList, Common, Draw, ExclGroup, Field, Font, HAlign, Layout, Margin, Node, Occur, PageArea, PageRole, Para, Placement,
PageArea, PageRole, Para, Placement, Presence, Rect, Script, Stroke, Subform, Template, Ui, VAlign, Value, Presence, Rect, Script, Stroke, Subform, Template, Ui, VAlign, Value,
}; };
use crate::text::{self, Block, Face, Span}; use crate::text::{self, Block, Face, Span};
+2 -3
View File
@@ -6,9 +6,8 @@ use roxmltree::Node as XmlNode;
use crate::XfaError; use crate::XfaError;
use crate::model::{ use crate::model::{
Access, Anchor, Area, Border, Caption, ChoiceList, Color, Common, Draw, Edge, ExclGroup, Field, FontSpec, Access, Anchor, Area, Border, Caption, ChoiceList, Color, Common, Draw, Edge, ExclGroup, Field, FontSpec, HAlign, Layout, Margin, Node, Occur,
HAlign, Layout, Margin, Node, Occur, PageArea, PageRole, PageSet, ParaSpec, Paragraph, Placement, Presence, PageArea, PageRole, PageSet, ParaSpec, Paragraph, Placement, Presence, Rect, RichText, Run, Script, Stroke, Subform, Template, Ui, VAlign, Value,
Rect, RichText, Run, Script, Stroke, Subform, Template, Ui, VAlign, Value,
}; };
/// Deepest element nesting followed (templates are shallow; hostile ones are not). /// Deepest element nesting followed (templates are shallow; hostile ones are not).