homepage/content/posts/rust-di-mocking.md

33 lines
865 B
Markdown
Raw Normal View History

2024-12-29 16:03:46 +01:00
+++
date = '2024-12-29T13:42:30+01:00'
draft = true
2024-12-29 17:05:17 +01:00
title = 'Mocking in Rust with Dependency Injection'
summary = "Learn more about me and why I am starting this blog."
tags = ["rust", "testing"]
2024-12-29 16:03:46 +01:00
+++
{{< lead >}}
Rust is hard.
{{< /lead >}}
2024-12-29 17:38:40 +01:00
That's one of my takeways from a recent endeavor during the winter break.
2024-12-29 16:03:46 +01:00
{{< forgejo repo="ghoscht/picoKontroller" >}}
2024-12-29 17:05:17 +01:00
## TL;DR
2024-12-29 16:03:46 +01:00
Rust isn't necessarily suited for pure object oriented programming.
2024-12-29 17:05:17 +01:00
## Getting Started
Use [Shaku](https://github.com/AzureMarker/shaku) and [Mockall](https://github.com/asomers/mockall)
2024-12-29 17:38:40 +01:00
{{< 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 >}}