use turso_ext::{register_extension, AggFunc, AggregateDerive, Value}; register_extension! { aggregates: { TestCount1a, TestCount1, TestCount2, TestCount3 } } #[derive(AggregateDerive)] struct TestCount1a; impl AggFunc for TestCount1a { type State = i64; type Error = &'static str; const NAME: &'static str = "test_count1a"; const ARGS: i32 = 0; fn step(state: &mut Self::State, args: &[Value]) { _ = args; *state += 1; } fn finalize(state: Self::State) -> Result { Ok(Value::from_integer(state)) } } #[derive(AggregateDerive)] struct TestCount1; impl AggFunc for TestCount1 { type State = i64; type Error = &'static str; const NAME: &'static str = "test_count1"; const ARGS: i32 = 1; fn step(state: &mut Self::State, args: &[Value]) { _ = args; *state += 1; } fn finalize(state: Self::State) -> Result { Ok(Value::from_integer(state)) } } #[derive(AggregateDerive)] struct TestCount2; impl AggFunc for TestCount2 { type State = i64; type Error = &'static str; const NAME: &'static str = "test_count2"; const ARGS: i32 = 1; fn step(state: &mut Self::State, args: &[Value]) { if let Some(x) = args.first().and_then(Value::to_integer) { _ = x; *state += 1; } } fn finalize(state: Self::State) -> Result { Ok(Value::from_integer(state)) } } #[derive(AggregateDerive)] struct TestCount3; impl AggFunc for TestCount3 { type State = i64; type Error = &'static str; const NAME: &'static str = "test_count3"; const ARGS: i32 = 1; fn step(state: &mut Self::State, args: &[Value]) { if let Some(x) = args.first().and_then(Value::to_float) { _ = x; *state += 1; } } fn finalize(state: Self::State) -> Result { Ok(Value::from_integer(state)) } }