4 releases

0.2.2 May 30, 2023
0.2.1 Jul 25, 2022
0.2.0 Feb 28, 2022
0.1.0 Nov 18, 2019

#707 in Configuration

Download history 49/week @ 2024-07-27 30/week @ 2024-08-03 24/week @ 2024-08-10 27/week @ 2024-08-17 28/week @ 2024-08-24 32/week @ 2024-08-31 31/week @ 2024-09-07 29/week @ 2024-09-14 43/week @ 2024-09-21 39/week @ 2024-09-28 82/week @ 2024-10-05 31/week @ 2024-10-12 30/week @ 2024-10-19 37/week @ 2024-10-26 41/week @ 2024-11-02 16/week @ 2024-11-09

125 downloads per month
Used in git-checks

MIT/Apache

165KB
4K SLoC

Configurations for Git checks

When using git checks, it is often useful to store what checks to read within configuration files. This crate allows for checks to also offer support for reading structures from configuration files and turning them into instances of checks. Another point is that adding another check to a crate requires consumers to update to consume that new check. Here, the [inventory][inventory] is used to create a global registry that consuming applications can use to automatically discover new checks added to the application from anywhere.

Caveats

One downside of this is that there is then one "blessed" serialization for a check. This crate aims to not preclude such uses and as such, checks themselves should generally not implement Deserialize. Instead, a separate structure should be created which then creates the check.

Example

struct MyCheck {
    field1: bool,
}

impl Check for MyCheck {
    // implementation
}

struct MyCheckConfig {
    #[serde(default)]
    field1: bool
}

impl IntoCheck for MyCheckConfig {
    type Check = MyCheck;

    fn into_check(self) -> Self::Check {
        MyCheck {
            field1: self.field1,
        }
    }
}

register_checks! {
    MyCheckConfig {
        "name_of_check" => CommitCheckConfig,
    }
}

Dependencies

~8–18MB
~263K SLoC