tnipv_lint/
modifiers.rs

1/*
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
5 */
6
7pub mod default_annotation;
8mod known_modifiers;
9
10use crate::lints::Context;
11use crate::LintSettings;
12
13pub use self::default_annotation::SetDefaultAnnotation;
14pub use self::known_modifiers::DefaultModifier;
15
16use snafu::Snafu;
17
18use std::fmt::Debug;
19
20#[derive(Debug, Snafu)]
21#[non_exhaustive]
22pub enum Error {
23    Custom {
24        source: Box<dyn std::error::Error + 'static>,
25    },
26}
27
28impl Error {
29    pub fn custom<E>(source: E) -> Self
30    where
31        E: 'static + std::error::Error,
32    {
33        Self::Custom {
34            source: Box::new(source) as Box<dyn std::error::Error>,
35        }
36    }
37}
38
39pub trait Modifier: Debug {
40    fn modify(&self, context: &Context, settings: &mut LintSettings) -> Result<(), Error>;
41}