Skip to main content

PluginSpec

Struct PluginSpec 

Source
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: String

Unique name for the rule (e.g., “my-custom-rule”)

§category: String

Category (e.g., “security”, “style”, “best_practices”, “custom”)

§description: String

Human-readable description

§api_version: String

API 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

Source

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

Source

pub fn with_severity(self, severity: impl Into<String>) -> Self

Set the severity level

Source

pub fn with_why(self, why: impl Into<String>) -> Self

Set the why documentation

Source

pub fn with_bad_example(self, example: impl Into<String>) -> Self

Set the bad example

Source

pub fn with_good_example(self, example: impl Into<String>) -> Self

Set the good example

Source

pub fn with_references(self, refs: Vec<String>) -> Self

Set references

Source

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

Source§

fn clone(&self) -> PluginSpec

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PluginSpec

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for PluginSpec

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for PluginSpec

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,