Functional State Machines in Rust: Typestate and Newtype Patterns