Welcome!
This is a landing page to look at other projects and bits I've noodled away at...
autospy
🎵 autospy record, autospy replace 🎵
A test spy object library.
Overview
A test spy is a type of test double used in unit testing. It provides the same interface as the production code, but allow you to set outputs before use in a test and to verify input parameters after the spy has been used.
#[autospy]
generates a test spy object for traits.
Usage
The example below demonstrates use in a unit test assuming autospy
is included in [dev-dependencies]
.
#![allow(unused)] fn main() { #[cfg(test)] use autospy::autospy; #[cfg_attr(test, autospy)] trait MyTrait { fn foo(&self, x: u32) -> bool; } fn use_trait(trait_object: impl MyTrait) -> bool { trait_object.foo(10) } #[cfg(test)] mod tests { use super::*; #[test] fn test_trait() { let spy = MyTraitSpy::default(); // build spy spy.foo.returns.push_back(true); // set the return value assert!(use_trait(spy.clone())); // use the spy assert_eq!(vec![10], spy.foo.arguments.take_all()) // verify the arguments passed } } }
For additional examples and features see the docs.
Acknowledgements
Autospy is heavily influenced by the excellent mockall crate, which, through automock, provides many similar features.
Autospy aims to offer these features through a macro-generated spy object, rather than a mock object. The use of either is largely personal preference; however, there are some advantages to using a spy object:
Test object | Test failures | Test structure | Complexity |
---|---|---|---|
Mock | Panics if expectations fail; error messages can be unclear | Less standard pattern, expectations are baked into object | More crate-specific syntax and usage patterns |
Spy | Asserts like any regular test | Assert after use, more standard test pattern | Simple: set what's returned, then inspect what was called |
licenses
Cargo subcommand for collecting licenses.
Install
$ cargo install licenses
Usage
$ cargo licenses --help
Usage: cargo licenses [OPTIONS] <COMMAND>
Commands:
collect Collects all licenses into a folder
summary Provides a summary of all licenses
Options:
-d, --dev Include dev dependencies [default: excluded]
-b, --build Include build dependencies [default: excluded]
-D, --depth <DEPTH> The depth of dependencies to include [default: all sub dependencies]
-e, --exclude <WORKSPACE> Exclude specified workspace [default: all included]
-i, --ignore <CRATE> Ignore specified crate [default: all included]
-h, --help Print help
Examples
Collect
$ cargo licenses collect --depth 1
licenses
├── anyhow-LICENSE-APACHE
├── anyhow-LICENSE-MIT
├── cargo_metadata-LICENSE-MIT
├── clap-LICENSE-APACHE
├── clap-LICENSE-MIT
├── colored-LICENSE
├── itertools-LICENSE-APACHE
├── itertools-LICENSE-MIT
├── serde_json-LICENSE-APACHE
└── serde_json-LICENSE-MIT
Summary
$ cargo licenses summary --depth 1 MIT: cargo_metadata MIT OR Apache-2.0: anyhow,clap,itertools,serde_json MPL-2.0: colored
$ cargo licenses summary --depth 1 --json
{
"MPL-2.0": [
"colored"
],
"MIT": [
"cargo_metadata"
],
"MIT OR Apache-2.0": [
"anyhow",
"clap",
"itertools",
"serde_json"
]
}
trust-list
Command line tool for generating a dependency information table in markdown.
Install
cargo install trust-list
Usage
$ trust-list --help
Command line tool for generating a dependency information table in markdown
Usage: trust-list [OPTIONS]
Options:
-o, --output-file <OUTPUT_FILE> The output filename, appended with .md [default: trust-list]
-r, --recreate Recreate table [default: appends new dependencies]
-D, --depth <DEPTH> The depth of dependencies to collect information on [default: all sub dependencies]
-d, --dev Include dev dependencies [default: excluded]
-b, --build Include build dependencies [default: excluded]
-e, --exclude <EXCLUDE> Exclude specified workspace [default: all included]
-h, --help Print help
-V, --version Print version
Example
trust-list --depth 1
name | downloads | contributors | reverse_dependencies | versions | created_at | updated_at | repository |
---|---|---|---|---|---|---|---|
anyhow | 362544609 | 23 | 20676 | 100 | 05/10/2019 | 14/04/2025 | https://github.com/dtolnay/anyhow |
chrono | 316490120 | 30+ | 14785 | 91 | 20/11/2014 | 29/04/2025 | https://github.com/chronotope/chrono |
clap | 455668951 | 30+ | 22736 | 433 | 01/03/2015 | 09/06/2025 | https://github.com/clap-rs/clap |
field_names | 534190 | 1 | 2 | 3 | 08/01/2021 | 04/01/2022 | https://github.com/TedDriggs/field_names |
itertools | 538150803 | 30+ | 6517 | 130 | 21/11/2014 | 31/12/2024 | https://github.com/rust-itertools/itertools |
pbr | 2573309 | 26 | 102 | 24 | 14/10/2015 | 08/02/2023 | https://github.com/a8m/pb |
reqwest | 236786443 | 30+ | 12502 | 113 | 16/10/2016 | 01/07/2025 | https://github.com/seanmonstar/reqwest |
serde | 572302147 | 30+ | 52086 | 306 | 05/12/2014 | 09/03/2025 | https://github.com/serde-rs/serde |
serde_json | 498510973 | 30+ | 36117 | 172 | 07/08/2015 | 03/03/2025 | https://github.com/serde-rs/json |
Compliance
Restricted to one request per second as per: crates.io data access policy
redacta
Command line tool for redacting information from text.
[!WARNING] This is an early stage implementation, it might not redact accurately.
Install
curl -sS https://raw.githubusercontent.com/lhalf/redacta/main/install.sh | sh
Or install via cargo:
cargo install redacta
Usage
Takes text via stdin and forwards redacted text to stdout.
$ redacta --help
Usage: <STDIN> | redacta [OPTIONS]
Options:
--ipv4 Enable IPv4 redaction
--ipv6 Enable IPv6 redaction
--fqdn Enable FQDN redaction
-r, --regex <REGEX> Regex redaction
-h, --help Print help
Example
$ echo "Look at my 192.168.0.1 IP!" | redacta --ipv4
Look at my *********** IP!
$ echo "No really, look at my 2001:db8:3333:4444:5555:6666:7777:8888 IP!" | redacta --ipv6
No really, look at my ************************************** IP!
$ echo "Okay, it is example.server.com here..." | redacta --fqdn
Okay, it is ****************** here...