expression

Separate socket error kind from operation phase

An error category is only one part of a retry decision. This toy policy allows a connection-stage refusal to be considered for retry, while a reset after sending is treated as an uncertain result. All retries still require authorization, a deadline and load policy. Expected stdout (not executed): consider retry uncertain stop Common mistake: Assigning a universal retry rule to each ErrorKind without knowing the operation phase.

Formal Syntax & Structure

rust syntaxrust
match (phase, error_kind)

Working Example

Example Snippetrust
fn main() {    use std::io::ErrorKind;    fn decision(sent: bool, kind: ErrorKind) -> &'static str {        match (sent, kind) {            (false, ErrorKind::ConnectionRefused) => "consider retry",            (true, ErrorKind::ConnectionReset | ErrorKind::TimedOut) => "uncertain",            _ => "stop",        }    }    println!("{}", decision(false, ErrorKind::ConnectionRefused));    println!("{}", decision(true, ErrorKind::ConnectionReset));    println!("{}", decision(false, ErrorKind::PermissionDenied));}
Rust Reference