pub trait SqliteAggregateFunction<Args>: Default {
    type Output;

    // Required methods
    fn step(&mut self, args: Args);
    fn finalize(aggregator: Option<Self>) -> Self::Output;
}
Available on crate feature sqlite only.
Expand description

Trait for the implementation of a SQLite aggregate function

This trait is to be used in conjunction with the sql_function! macro for defining a custom SQLite aggregate function. See the documentation there for details.

Required Associated Types§

source

type Output

The result type of the SQLite aggregate function

Required Methods§

source

fn step(&mut self, args: Args)

The step() method is called once for every record of the query.

This is called through a C FFI, as such panics do not propagate to the caller. Panics are caught and cause a return with an error value. The implementation must still ensure that state remains in a valid state (refer to std::panic::UnwindSafe for a bit more detail).

source

fn finalize(aggregator: Option<Self>) -> Self::Output

After the last row has been processed, the finalize() method is called to compute the result of the aggregate function. If no rows were processed aggregator will be None and finalize() can be used to specify a default result.

This is called through a C FFI, as such panics do not propagate to the caller. Panics are caught and cause a return with an error value.

Implementors§