~/talk

Refactoring in Rust

Talkat RustWeek 2025 · 2025-05-13..05-17· [rust, developer-experience]
slides:none on file

A weekend-prototype Rust web app using axum and the image crate gets refactored into clear, testable pieces: unwraps and expects are removed in favor of ? propagation; a KVError struct holding an axum StatusCode implements From for poison and image errors and IntoResponse; a TryFrom<DynamicImage> -> ImageResponse hides buffer and PNG conversion; stored values become an enum StoredItem and a database trait lets the hashmap swap for a real DB, reducing grayscale to a one-line call and enabling thumbnails.

AI-written summary · about

  1. 0:00Introduction
  2. 1:27Refactoring scenario setup
  3. 2:50Messy codebase examination
  4. 7:28Error handling with custom types
  5. 13:05Type-driven refactoring for images
  6. 18:45Type-driven design philosophy
  7. 19:06Refactoring storage with enums
  8. 23:45Final refactored code
  9. 27:15Refactoring improves efficiency
  10. 28:20Trait implementation scene
  11. 29:45Q&A
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.