Skip to main content

BuildMod

Trait BuildMod 

Source
pub trait BuildMod<Q>:
    Debug
    + Send
    + Sync {
    // Required method
    fn apply(&self, q: &mut Q) -> Result<()>;
}
Expand description

A mod that runs when the query is built rather than when it is assembled.

bob calls these contextual mods. They exist for what cannot be decided at assembly time — a WHERE that depends on the schema in use, say — and they run on every build, so a query keeps them as Vec<Arc<dyn BuildMod<Q>>> and applies them to a clone of itself at the top of write_sql.

&self rather than self, because unlike a Mod they are applied more than once. Unlike rendering they can fail, and they run before there is any SQL to attach a failure to, so this one returns a Result; the caller records it on the writer.

Required Methods§

Source

fn apply(&self, q: &mut Q) -> Result<()>

Apply this modification to q, or explain why it cannot be applied.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<Q, T: BuildMod<Q> + ?Sized> BuildMod<Q> for Arc<T>

Source§

fn apply(&self, q: &mut Q) -> Result<()>

Source§

impl<Q, T: BuildMod<Q> + ?Sized> BuildMod<Q> for Box<T>

Source§

fn apply(&self, q: &mut Q) -> Result<()>

Implementors§