Trait LegacyAggregateFunction

Source
pub trait LegacyAggregateFunction<UserData>: FromUserData<UserData> {
    // Required methods
    fn step(
        &mut self,
        context: &Context,
        args: &mut [&mut ValueRef],
    ) -> Result<()>;
    fn value(&self, context: &Context) -> Result<()>;

    // Provided method
    fn default_value(user_data: &UserData, context: &Context) -> Result<()>
       where Self: Sized { ... }
}
Expand description

Implement an application-defined aggregate function which cannot be used as a window function.

In general, there is no reason to implement this trait instead of AggregateFunction, because the latter provides a blanket implementation of the former.

Required Methods§

Source

fn step(&mut self, context: &Context, args: &mut [&mut ValueRef]) -> Result<()>

Add a new row to the aggregate.

Source

fn value(&self, context: &Context) -> Result<()>

Assign the current value of the aggregate function to the context using Context::set_result. If no result is set, SQL NULL is returned. If the function returns an Err value, the SQL statement will fail, even if a result had been set before the failure.

Provided Methods§

Source

fn default_value(user_data: &UserData, context: &Context) -> Result<()>
where Self: Sized,

Assign the default value of the aggregate function to the context using Context::set_result.

This method is called when the aggregate function is invoked over an empty set of rows. The default implementation is equivalent to Self::from_user_data(user_data).value(context).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§