implement query_as!() et al, document query macros

This commit is contained in:
Austin Bonander
2019-12-20 17:51:06 -08:00
committed by Ryan Leckey
parent 56a82346f2
commit 7d745f98ea
31 changed files with 1109 additions and 382 deletions

View File

@@ -193,7 +193,7 @@ impl PgConnection {
}
impl PgConnection {
async fn open(url: crate::Result<Url>) -> crate::Result<Self> {
pub(super) async fn open(url: crate::Result<Url>) -> crate::Result<Self> {
let url = url?;
let stream = TcpStream::connect((url.host(), url.port(5432))).await?;
let mut self_ = Self {

View File

@@ -10,3 +10,5 @@ impl Database for Postgres {
type Row = super::PgRow;
}
impl_into_arguments_for_database!(Postgres);

View File

@@ -291,13 +291,9 @@ impl super::PgConnection {
name: field.name,
table_id: field.table_id,
type_id: field.type_id,
_non_exhaustive: (),
})
.collect::<Vec<_>>()
.into_boxed_slice(),
_non_exhaustive: (),
})
}
}

View File

@@ -1,5 +1,15 @@
//! **Postgres** database and connection types.
use std::convert::TryInto;
pub use arguments::PgArguments;
pub use connection::PgConnection;
pub use database::Postgres;
pub use error::PgError;
pub use row::PgRow;
use crate::url::Url;
mod arguments;
mod connection;
mod database;
@@ -9,15 +19,14 @@ mod protocol;
mod row;
mod types;
pub use database::Postgres;
pub use arguments::PgArguments;
pub use connection::PgConnection;
pub use error::PgError;
pub use row::PgRow;
/// An alias for [`Pool`], specialized for **Postgres**.
pub type PgPool = super::Pool<Postgres>;
// used in tests and hidden code in examples
#[doc(hidden)]
pub async fn connect<T>(url: T) -> crate::Result<PgConnection>
where
T: TryInto<Url, Error = crate::Error>
{
PgConnection::open(url.try_into()).await
}