pub struct PgTypeInfo(/* private fields */);
postgres
only.Expand description
Type information for a PostgreSQL type.
Implementations§
Source§impl PgTypeInfo
impl PgTypeInfo
Sourcepub fn kind(&self) -> &PgTypeKind
pub fn kind(&self) -> &PgTypeKind
Returns the kind (simple, array, enum, etc.) for this type.
Sourcepub fn oid(&self) -> Option<Oid>
pub fn oid(&self) -> Option<Oid>
Returns the OID for this type, if available.
The OID may not be available if SQLx only knows the type by name.
It will have to be resolved by a PgConnection
at runtime which
will yield a new and semantically distinct TypeInfo
instance.
This method does not perform any such lookup.
§Note
With the exception of the default pg_type
catalog, type OIDs are not stable in PostgreSQL.
If a type is added by an extension, its OID will be assigned when the CREATE EXTENSION
statement is executed,
and so can change depending on what extensions are installed and in what order, as well as the exact
version of PostgreSQL.
Sourcepub const fn with_name(name: &'static str) -> PgTypeInfo
pub const fn with_name(name: &'static str) -> PgTypeInfo
Create a PgTypeInfo
from a type name.
The OID for the type will be fetched from Postgres on use of a value of this type. The fetched OID will be cached per-connection.
Sourcepub const fn with_oid(oid: Oid) -> PgTypeInfo
pub const fn with_oid(oid: Oid) -> PgTypeInfo
Create a PgTypeInfo
from an OID.
Note that the OID for a type is very dependent on the environment. If you only ever use
one database or if this is an unhandled built-in type, you should be fine. Otherwise,
you will be better served using with_name
.
Trait Implementations§
Source§impl Clone for PgTypeInfo
impl Clone for PgTypeInfo
Source§fn clone(&self) -> PgTypeInfo
fn clone(&self) -> PgTypeInfo
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for PgTypeInfo
impl Debug for PgTypeInfo
Source§impl Deref for PgTypeInfo
impl Deref for PgTypeInfo
Source§impl Display for PgTypeInfo
impl Display for PgTypeInfo
Source§impl PartialEq for PgTypeInfo
impl PartialEq for PgTypeInfo
Source§impl<'a> TryFrom<&'a PgTypeInfo> for AnyTypeInfo
impl<'a> TryFrom<&'a PgTypeInfo> for AnyTypeInfo
Source§fn try_from(
pg_type: &'a PgTypeInfo,
) -> Result<AnyTypeInfo, <AnyTypeInfo as TryFrom<&'a PgTypeInfo>>::Error>
fn try_from( pg_type: &'a PgTypeInfo, ) -> Result<AnyTypeInfo, <AnyTypeInfo as TryFrom<&'a PgTypeInfo>>::Error>
Source§impl TypeInfo for PgTypeInfo
impl TypeInfo for PgTypeInfo
Source§fn name(&self) -> &str
fn name(&self) -> &str
VARCHAR
, TEXT
, or INT
. Type names should be uppercase. They
should be a rough approximation of how they are written in SQL in the given database.fn is_null(&self) -> bool
impl StructuralPartialEq for PgTypeInfo
Auto Trait Implementations§
impl Freeze for PgTypeInfo
impl RefUnwindSafe for PgTypeInfo
impl Send for PgTypeInfo
impl Sync for PgTypeInfo
impl Unpin for PgTypeInfo
impl UnwindSafe for PgTypeInfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more