ElyPDF: an OS permission error shows as an error, never a missing text key (P-01); component library f834f55

This commit is contained in:
ZacharyZhang-NY committed 2026-10-09 10:58:47 -04:00
1 parent ab85673eea
commit 943411fb1a
17 files changed
+90 -25

No files matched your search

+23 -3
View File
@@ -293,10 +293,30 @@ impl Drop for Worker {
}
}
/// A permission refusal is `PermissionDenied`, named by what it needs.
/// A request the document's permissions refused, by what it needs.
#[derive(Debug)]
pub struct Refused(pub &'static str);
impl std::fmt::Display for Refused {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}{}", crate::proto::may::REFUSED, self.0)
}
}
impl std::error::Error for Refused {}
/// What a permission refusal needs; none for other errors.
pub fn refused(error: &io::Error) -> Option<&'static str> {
error.get_ref()?.downcast_ref::<Refused>().map(|refused| refused.0)
}
/// A worker error; a refusal names a permission it knows.
fn refusal(text: String) -> io::Error {
match text.strip_prefix(crate::proto::may::REFUSED) {
Some(needed) => io::Error::new(io::ErrorKind::PermissionDenied, needed.to_string()),
let named = text
.strip_prefix(crate::proto::may::REFUSED)
.and_then(|needed| crate::proto::may::NAMES.iter().find(|(_, name)| *name == needed));
match named {
Some((_, name)) => io::Error::other(Refused(name)),
None => io::Error::other(text),
}
}
+1 -1
View File
@@ -14,7 +14,7 @@ pub mod proto;
#[cfg(any(test, feature = "test-support"))]
pub mod sample;
pub use client::{Doc, Opened, Tile, Worker, is_stale};
pub use client::{Doc, Opened, Refused, Tile, Worker, is_stale, refused};
pub use content::{Drawn, TextBlock, Writing, Wrote};
pub use ocr::{OcrLine, tessdata};
pub use output::Optimizing;