pub struct IoContext {
pub context: &'static str,
pub detail: String,
}Expand description
Pairs a static, non-path-bearing summary with the dynamic detail of an
I/O failure constructed via [std::io::Error::other].
FFI bindings redact ArchiveError::Io messages down to their
std::io::ErrorKind description in release builds, since free-form
messages have no structured path field to sanitize. For errors built
from ErrorKind::Other, that redaction collapses to the fixed string
“other error”, discarding all diagnostic value. Wrapping the detail in
IoContext lets bindings recognize the error (via
std::io::Error::get_ref and downcasting) and surface context
instead — safe to show even in release builds because it is always a
&'static str fixed at the call site, never built from path or archive
entry data.
§Examples
use exarch_core::IoContext;
use std::io;
let err = io::Error::other(IoContext::new(
"failed to read entry metadata",
"/tmp/x: denied",
));
assert_eq!(
err.to_string(),
"failed to read entry metadata: /tmp/x: denied"
);
let ctx = err
.get_ref()
.and_then(|inner| inner.downcast_ref::<IoContext>())
.expect("IoContext downcast");
assert_eq!(ctx.context, "failed to read entry metadata");Fields§
§context: &'static strStatic summary of the failure. Never carries path or archive entry data — safe to surface in release builds.
detail: StringFull dynamic detail (may embed a host path). Shown only in debug
builds via ArchiveError::Io’s Display.
Implementations§
Source§impl IoContext
impl IoContext
Sourcepub fn new(context: &'static str, detail: impl Into<String>) -> Self
pub fn new(context: &'static str, detail: impl Into<String>) -> Self
Creates a new IoContext pairing a static summary with dynamic
detail.
§Examples
use exarch_core::IoContext;
let ctx = IoContext::new("failed to start file in zip archive", "boom");
assert_eq!(ctx.context, "failed to start file in zip archive");
assert_eq!(ctx.detail, "boom");Trait Implementations§
Source§impl Error for IoContext
impl Error for IoContext
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()