pub struct Type {
pub oid: Oid,
pub modifier: Option<i32>,
}Expand description
Hyper SQL type information (OID + optional modifier).
The modifier encodes type-specific parameters using PostgreSQL conventions:
- NUMERIC:
((precision << 16) | scale) + 4 - VARCHAR:
max_length + 4 - CHAR:
length + 4
The + 4 offset is a PostgreSQL convention that reserves values < 4 as
“unspecified”. See SqlType::from_oid_and_modifier
for the decoding logic.
Fields§
§oid: OidThe type OID
modifier: Option<i32>Type modifier (e.g., VARCHAR length, NUMERIC precision/scale)
Implementations§
Source§impl Type
impl Type
Sourcepub const fn with_modifier(oid: Oid, modifier: i32) -> Type
pub const fn with_modifier(oid: Oid, modifier: i32) -> Type
Creates a new Type with the given OID and modifier.
Sourcepub fn is_variable_length(&self) -> bool
pub fn is_variable_length(&self) -> bool
Returns true if this is a variable-length type.
Sourcepub fn fixed_size(&self) -> Option<usize>
pub fn fixed_size(&self) -> Option<usize>
Returns the fixed size of this type in bytes, if it has a fixed size.
Source§impl Type
impl Type
Sourcepub const fn timestamp_tz() -> Type
pub const fn timestamp_tz() -> Type
TIMESTAMPTZ type
Sourcepub const fn numeric_with_precision(precision: i32, scale: i32) -> Type
pub const fn numeric_with_precision(precision: i32, scale: i32) -> Type
NUMERIC with precision and scale.
§Panics
Panics if:
precisionis not in range1..=38(Numeric::MAX_PRECISION)scaleis negative or greater thanprecision
§Example
use hyperdb_api_core::types::Type;
let decimal = Type::numeric_with_precision(10, 2); // NUMERIC(10, 2)Trait Implementations§
impl Copy for Type
impl Eq for Type
impl StructuralPartialEq for Type
Auto Trait Implementations§
impl Freeze for Type
impl RefUnwindSafe for Type
impl Send for Type
impl Sync for Type
impl Unpin for Type
impl UnsafeUnpin for Type
impl UnwindSafe for Type
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request