Strand Errors
Internals
Internals of `strand-errors` — shared error enums, error code mapping, IO bridges, and serialisation rules.
Purpose
Shared error hierarchy, serialization, context wrappers, error codes, and IO mapping.
This page follows the real source shape for Strand Errors and explains the workflow a developer is likely to use first.
Developer workflow
Start from the smallest constructor or builder, perform one meaningful operation, inspect the returned state, then add the relevant policy, storage, or network integration. The examples below should be expanded whenever the crate API changes.
Primary types to know
SerializedError— libs/strand-errors/src/lib.rsCryptoError— libs/strand-errors/src/lib.rsErrorCode— libs/strand-errors/src/lib.rsOwnershipError— libs/strand-errors/src/lib.rsProtocolError— libs/strand-errors/src/lib.rsReplicationError— libs/strand-errors/src/lib.rsStorageError— libs/strand-errors/src/lib.rsStrandError— libs/strand-errors/src/lib.rsValidationError— libs/strand-errors/src/lib.rsErrorContext— libs/strand-errors/src/lib.rsToIoErrorKind— libs/strand-errors/src/lib.rs
Example shape
use std::io;
use strand_errors::{StrandError, ToIoErrorKind};
fn main() {
// Every error variant the crate emits. Pattern-match on these names —
// the discriminator is stable across releases.
let samples = vec![
StrandError::Storage("disk full".into()),
StrandError::Signature("bad signature".into()),
StrandError::InvalidBlock("seq out of range".into()),
StrandError::Policy("policy denied".into()),
StrandError::PolicyDenied,
StrandError::Io(io::Error::new(io::ErrorKind::PermissionDenied, "ro fs")),
];
for err in &samples {
// ToIoErrorKind maps a StrandError to the closest std::io::ErrorKind,
// useful when a caller wants to surface a single uniform error type.
let kind = err.to_io_error_kind();
eprintln!("variant={} io_kind={:?}", err, kind);
}
}