feat(postgres): expose PgTypeKind

This commit is contained in:
Ryan Leckey 2020-07-24 07:28:59 -07:00
parent f0f93c4f79
commit 08d2c79279
3 changed files with 5 additions and 6 deletions

View File

@ -32,7 +32,7 @@ pub use options::{PgConnectOptions, PgSslMode};
pub use row::PgRow;
pub use statement::PgStatement;
pub use transaction::PgTransactionManager;
pub use type_info::PgTypeInfo;
pub use type_info::{PgTypeInfo, PgTypeKind};
pub use value::{PgValue, PgValueFormat, PgValueRef};
/// An alias for [`Pool`][crate::pool::Pool], specialized for Postgres.

View File

@ -141,7 +141,6 @@ pub struct PgCustomType {
#[derive(Debug, Clone)]
#[cfg_attr(feature = "offline", derive(serde::Serialize, serde::Deserialize))]
#[doc(hidden)]
pub enum PgTypeKind {
Simple,
Pseudo,
@ -158,8 +157,8 @@ impl PgTypeInfo {
PgType::try_from_oid(oid).map(Self)
}
#[doc(hidden)]
pub fn __kind(&self) -> &PgTypeKind {
/// Returns the _kind_ (simple, array, enum, etc.) for this type.
pub fn kind(&self) -> &PgTypeKind {
self.0.kind()
}

View File

@ -55,7 +55,7 @@ async fn it_describes_enum() -> anyhow::Result<()> {
assert_eq!(ty.name(), "status");
assert_eq!(
format!("{:?}", ty.__kind()),
format!("{:?}", ty.kind()),
r#"Enum(["new", "open", "closed"])"#
);
@ -87,7 +87,7 @@ async fn it_describes_composite() -> anyhow::Result<()> {
assert_eq!(ty.name(), "inventory_item");
assert_eq!(
format!("{:?}", ty.__kind()),
format!("{:?}", ty.kind()),
r#"Composite([("name", PgTypeInfo(Text)), ("supplier_id", PgTypeInfo(Int4)), ("price", PgTypeInfo(Int8))])"#
);