Rule

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 for rules that can transform Lua blocks.

Rules implement this trait to define how they process blocks and how their configuration can be serialized and deserialized.

Required Methods§

Source

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

Processes the given block to apply the rule’s transformation.

Returns Ok(()) if the transformation was successful, or an error message if it failed.

Provided Methods§

Source

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

Returns a list of paths to Lua files that are required to apply this rule.

These files will be loaded into the context for use during processing.

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§