A trait for types that can execute raw queries.
| 7 | |
| 8 | /// A trait for types that can execute raw queries. |
| 9 | pub trait Queryable { |
| 10 | /// The type of a connection to the database. |
| 11 | type Connection; |
| 12 | |
| 13 | /// The type of a stream containing the query results. |
| 14 | type QueryStream: Stream<Item = Result<QueryResult, Status>> + Unpin; |
| 15 | |
| 16 | /// Execute a query and return a stream of results. |
| 17 | /// |
| 18 | /// The connection is passed by ownership, but must be returned in the output tuple. |
| 19 | fn query( |
| 20 | query: String, |
| 21 | conn: Self::Connection, |
| 22 | ) -> impl Future<Output = (Self::QueryStream, Self::Connection)> + Send; |
| 23 | |
| 24 | /// Execute a query that does not return rows, but returns the number of rows changed. |
| 25 | /// |
| 26 | /// This is used for queries that modify the database. |
| 27 | fn execute( |
| 28 | query: String, |
| 29 | conn: Self::Connection, |
| 30 | ) -> impl Future<Output = (Result<RowsChanged, Status>, Self::Connection)> + Send; |
| 31 | } |
nothing calls this directly
no outgoing calls
no test coverage detected