Trait Rule

Source
pub trait Rule: RuleConfiguration + Debug {
    // Required method
    fn process(
        &self,
        block: &mut Block,
        context: &Context<'_, '_, '_>,
    ) -> RuleProcessResult;

    // Provided method
    fn require_content(
        &self,
        _current_source: &Path,
        _current_block: &Block,
    ) -> Vec<PathBuf> { ... }
}
Expand description

Defines an interface that will be used to mutate blocks and how to serialize and deserialize the rule configuration.

Required Methods§

Source

fn process( &self, block: &mut Block, context: &Context<'_, '_, '_>, ) -> RuleProcessResult

This method should mutate the given block to apply the rule

Provided Methods§

Source

fn require_content( &self, _current_source: &Path, _current_block: &Block, ) -> Vec<PathBuf>

Return the list of paths to Lua files that is necessary to apply this rule. This will load each AST block from these files into the context object.

Trait Implementations§

Source§

impl<'de> Deserialize<'de> for Box<dyn Rule>

Source§

fn deserialize<D: Deserializer<'de>>( deserializer: D, ) -> Result<Box<dyn Rule>, D::Error>

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

impl FromStr for Box<dyn Rule>

Source§

type Err = String

The associated error which can be returned from parsing.
Source§

fn from_str(string: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Serialize for dyn Rule

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more

Implementors§