diff --git a/server/crates/arbiter-terrors-poc/src/main.rs b/server/crates/arbiter-terrors-poc/src/main.rs index a3bef62..d8e2f7a 100644 --- a/server/crates/arbiter-terrors-poc/src/main.rs +++ b/server/crates/arbiter-terrors-poc/src/main.rs @@ -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::() { + 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 +}