#[repr(u8)]pub enum IntWidth {
I16 = 0,
I32 = 1,
I64 = 2,
}Expand description
The declared width of an integer column.
Ordered narrow → wide; I64 is the storage width and the default for an
integer column whose declared type carries no width information.
Variants§
I16 = 0
SMALLINT / INT2 — 2 bytes on the wire, PostgreSQL OID 21.
I32 = 1
INTEGER / INT / INT4 — 4 bytes on the wire, PostgreSQL OID 23.
I64 = 2
BIGINT / INT8 / INT64 — 8 bytes on the wire, PostgreSQL OID 20.
Implementations§
Source§impl IntWidth
impl IntWidth
Sourcepub fn from_declared_type(declared: &str) -> Option<Self>
pub fn from_declared_type(declared: &str) -> Option<Self>
Resolve a declared SQL type string to an integer width, or None when
the string does not name an integer type.
Matching is case-insensitive and boundary-aware: a keyword matches when
the (trimmed, lowercased) input either equals it exactly or is followed
by ( or whitespace, so trailing modifiers ("BIGINT NOT NULL") and
parameterised spellings still resolve. The boundary check is also what
keeps int from swallowing int2/int4/int8/int64 as prefixes —
the next character is a digit, which is neither ( nor whitespace —
so the arm order below is not load-bearing.
This is the single source of truth for keyword → width. Callers that need an OID or a range check derive it from the returned width rather than re-parsing the string.
Sourcepub const fn range(self) -> (i64, i64)
pub const fn range(self) -> (i64, i64)
The inclusive value range a column of this width accepts.
Sourcepub const fn contains(self, value: i64) -> bool
pub const fn contains(self, value: i64) -> bool
Whether value fits in a column of this declared width.
Sourcepub const fn pg_oid(self) -> u32
pub const fn pg_oid(self) -> u32
The PostgreSQL type OID a column of this width advertises in
RowDescription and in catalog introspection.
Sourcepub const fn pg_type_name(self) -> &'static str
pub const fn pg_type_name(self) -> &'static str
The canonical PostgreSQL type name, for error messages that must read
like PostgreSQL’s own (integer out of range).
Trait Implementations§
impl Copy for IntWidth
Source§impl<'de> Deserialize<'de> for IntWidth
impl<'de> Deserialize<'de> for IntWidth
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for IntWidth
Source§impl<'__msgpack_de> FromMessagePack<'__msgpack_de> for IntWidth
impl<'__msgpack_de> FromMessagePack<'__msgpack_de> for IntWidth
Source§impl Ord for IntWidth
impl Ord for IntWidth
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for IntWidth
impl PartialOrd for IntWidth
impl StructuralPartialEq for IntWidth
Source§impl ToMessagePack for IntWidth
impl ToMessagePack for IntWidth
Source§fn write<W: Write>(&self, writer: &mut W) -> Result<(), Error>
fn write<W: Write>(&self, writer: &mut W) -> Result<(), Error>
Source§fn write_slice<W>(values: &[Self], writer: &mut W) -> Result<(), Error>
fn write_slice<W>(values: &[Self], writer: &mut W) -> Result<(), Error>
Source§fn size_hint(&self) -> Option<TrustedSizeHint>
fn size_hint(&self) -> Option<TrustedSizeHint>
Self::write, or None when it cannot be determined cheaply. Read moreAuto Trait Implementations§
impl Freeze for IntWidth
impl RefUnwindSafe for IntWidth
impl Send for IntWidth
impl Sync for IntWidth
impl Unpin for IntWidth
impl UnsafeUnpin for IntWidth
impl UnwindSafe for IntWidth
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
impl<T> FromMessagePackOwned for Twhere
T: for<'a> FromMessagePack<'a>,
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> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.