pub struct PluginSpec {
pub name: String,
pub category: String,
pub description: String,
pub api_version: String,
pub severity: Option<String>,
pub why: Option<String>,
pub bad_example: Option<String>,
pub good_example: Option<String>,
pub references: Option<Vec<String>>,
}Expand description
Plugin metadata describing a lint rule.
Created via PluginSpec::new() and configured with builder methods.
§Example
use nginx_lint_plugin::PluginSpec;
let spec = PluginSpec::new("my-rule", "security", "Short description")
.with_severity("warning")
.with_why("Detailed explanation of why this rule exists.")
.with_bad_example("server {\n bad_directive on;\n}")
.with_good_example("server {\n bad_directive off;\n}")
.with_references(vec![
"https://nginx.org/en/docs/...".to_string(),
]);
assert_eq!(spec.name, "my-rule");
assert_eq!(spec.category, "security");
assert_eq!(spec.severity, Some("warning".to_string()));Fields§
§name: StringUnique name for the rule (e.g., “my-custom-rule”)
category: StringCategory (e.g., “security”, “style”, “best_practices”, “custom”)
description: StringHuman-readable description
api_version: StringAPI version the plugin uses for input/output format
severity: Option<String>Severity level (error, warning)
why: Option<String>Why this rule exists (detailed explanation)
bad_example: Option<String>Example of bad configuration
good_example: Option<String>Example of good configuration
references: Option<Vec<String>>References (URLs, documentation links)
Implementations§
Source§impl PluginSpec
impl PluginSpec
Sourcepub fn new(
name: impl Into<String>,
category: impl Into<String>,
description: impl Into<String>,
) -> Self
pub fn new( name: impl Into<String>, category: impl Into<String>, description: impl Into<String>, ) -> Self
Create a new PluginSpec with the current API version
Sourcepub fn with_severity(self, severity: impl Into<String>) -> Self
pub fn with_severity(self, severity: impl Into<String>) -> Self
Set the severity level
Sourcepub fn with_bad_example(self, example: impl Into<String>) -> Self
pub fn with_bad_example(self, example: impl Into<String>) -> Self
Set the bad example
Sourcepub fn with_good_example(self, example: impl Into<String>) -> Self
pub fn with_good_example(self, example: impl Into<String>) -> Self
Set the good example
Sourcepub fn with_references(self, refs: Vec<String>) -> Self
pub fn with_references(self, refs: Vec<String>) -> Self
Set references
Sourcepub fn error_builder(&self) -> ErrorBuilder
pub fn error_builder(&self) -> ErrorBuilder
Create an error builder that uses this plugin’s name and category
This reduces boilerplate when creating errors in the check method.
§Example
use nginx_lint_plugin::{PluginSpec, Severity};
let spec = PluginSpec::new("my-rule", "security", "Check something");
let err = spec.error_builder();
// Instead of:
// LintError::warning("my-rule", "security", "message", 10, 5)
// Use:
let warning = err.warning("message", 10, 5);
assert_eq!(warning.rule, "my-rule");
assert_eq!(warning.category, "security");
assert_eq!(warning.severity, Severity::Warning);Trait Implementations§
Source§impl Clone for PluginSpec
impl Clone for PluginSpec
Source§fn clone(&self) -> PluginSpec
fn clone(&self) -> PluginSpec
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PluginSpec
impl Debug for PluginSpec
Source§impl<'de> Deserialize<'de> for PluginSpec
impl<'de> Deserialize<'de> for PluginSpec
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for PluginSpec
impl RefUnwindSafe for PluginSpec
impl Send for PluginSpec
impl Sync for PluginSpec
impl Unpin for PluginSpec
impl UnsafeUnpin for PluginSpec
impl UnwindSafe for PluginSpec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more