[repo] Format, clippy clean, FORMATS.md, the full crate table in DEPENDENCIES.md

This commit is contained in:
2026-11-16 13:58:06 +01:00
parent 196802863a
commit a06e3f9b73
17 changed files with 2708 additions and 2125 deletions
+11 -4
View File
@@ -52,7 +52,8 @@ pub fn redact(
redactions: &[Redaction],
opts: &RedactOptions,
) -> Result<Redacted, PdfError> {
if redactions.is_empty() || redactions.iter().any(|r| r.rects.is_empty() || r.rects.iter().any(ViewRect::is_empty)) {
if redactions.is_empty() || redactions.iter().any(|r| r.rects.is_empty() || r.rects.iter().any(ViewRect::is_empty))
{
return Err(PdfError::Invalid("Draw at least one box to redact.".into()));
}
// 1. Render every redacted page with pdfium (annotations and form fields included) and burn the boxes in.
@@ -67,7 +68,8 @@ pub fn redact(
if !seen.insert(r.page) {
continue;
}
let rects: Vec<ViewRect> = redactions.iter().filter(|x| x.page == r.page).flat_map(|x| x.rects.clone()).collect();
let rects: Vec<ViewRect> =
redactions.iter().filter(|x| x.page == r.page).flat_map(|x| x.rects.clone()).collect();
let page = pdfium_doc.pages().get(r.page as i32).map_err(PdfError::from_pdfium)?;
let (vw, vh) = (page.width().value, page.height().value);
drop(page);
@@ -181,7 +183,8 @@ fn push_down_resources(doc: &mut Document, pages: &[ObjectId], redacted: &HashSe
for &page in pages {
// The nearest ancestor's /Resources, and every Pages node on the way up.
let mut inherited = None;
let mut current = doc.get_dictionary(page).ok().and_then(|d| d.get(b"Parent").ok()).and_then(|p| p.as_reference().ok());
let mut current =
doc.get_dictionary(page).ok().and_then(|d| d.get(b"Parent").ok()).and_then(|p| p.as_reference().ok());
let mut depth = 0;
while let Some(id) = current {
if depth > 64 || !nodes.insert(id) && inherited.is_some() {
@@ -272,7 +275,11 @@ fn prune_form(doc: &mut Document, removed: &HashSet<ObjectId>) {
if changed {
let target = match acroform {
Some(id) => doc.get_dictionary_mut(id).ok(),
None => doc.get_dictionary_mut(catalog_id).ok().and_then(|c| c.get_mut(b"AcroForm").ok()).and_then(|o| o.as_dict_mut().ok()),
None => doc
.get_dictionary_mut(catalog_id)
.ok()
.and_then(|c| c.get_mut(b"AcroForm").ok())
.and_then(|o| o.as_dict_mut().ok()),
};
if let Some(f) = target {
f.set("Fields", kept);