feat(poc): complete terrors PoC with main scenarios

This commit is contained in:
CleverWild
2026-03-15 19:24:49 +01:00
parent 3360d3c8c7
commit 66026e903a

View File

@@ -1,5 +1,26 @@
mod errors;
mod db;
mod auth;
mod db;
mod errors;
fn main() {}
use errors::ProtoError;
fn run(id: u32, sig: &str) {
print!("authenticate(id={id}, sig={sig:?}) => ");
match auth::authenticate(id, sig) {
Ok(nonce) => println!("Ok(nonce={nonce})"),
Err(e) => match e.narrow::<errors::NotRegistered, _>() {
Ok(_) => println!("Err(NotRegistered) — handled locally"),
Err(remaining) => {
let proto = ProtoError::from(remaining);
println!("Err(ProtoError::{proto:?}) — forwarded to wire");
}
},
}
}
fn main() {
run(0, "ok"); // NotRegistered
run(1, "bad"); // InvalidSignature
run(99, "ok"); // Internal
run(1, "ok"); // success
}