homepage/content/posts/rust-di-mocking.md
GHOSCHT 3137e0c382
All checks were successful
Homepage deployment / deploy (push) Successful in 1m56s
Add example code snippet
2024-12-29 17:38:40 +01:00

32 lines
865 B
Markdown

+++
date = '2024-12-29T13:42:30+01:00'
draft = true
title = 'Mocking in Rust with Dependency Injection'
summary = "Learn more about me and why I am starting this blog."
tags = ["rust", "testing"]
+++
{{< lead >}}
Rust is hard.
{{< /lead >}}
That's one of my takeways from a recent endeavor during the winter break.
{{< forgejo repo="ghoscht/picoKontroller" >}}
## TL;DR
Rust isn't necessarily suited for pure object oriented programming.
## Getting Started
Use [Shaku](https://github.com/AzureMarker/shaku) and [Mockall](https://github.com/asomers/mockall)
{{< highlight rust "linenos=table" >}}
#[derive(Parser)]
#[command(version, about, long_about = None)]
struct Cli {
#[arg(long, help = "List all available MIDI devices.")]
list_midi: bool,
#[arg(long, help = "List all available MPRIS players.")]
list_mpris: bool,
}
{{< / highlight >}}