pub trait Verifier {
// Required method
fn verify(&self, data: &[u8], signature: &[u8]) -> Result<bool, VctrlError>;
}Expand description
A digital signature verifier.
Matches a Signer implementation. Given data and a signature, returns
Ok(true) if the signature is valid, Ok(false) if it is not.
§Why not Result<bool, …> where false is an error?
Because an invalid signature is not a system failure – it’s an expected outcome during verification. Errors should be reserved for cases where the verifier cannot operate (e.g., missing key, corrupted key).
§Example (stub)
use libvctrl_handler::{Verifier, VctrlError};
struct StubVerifier;
impl Verifier for StubVerifier {
fn verify(&self, data: &[u8], signature: &[u8]) -> Result<bool, VctrlError> {
// Dummy check: signature is valid iff it equals the data.
Ok(data == signature)
}
}Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".