pub enum SqlType {
}Expand description
SQL type tags that identify the type of a column.
Each variant corresponds to a Hyper SQL type and has an associated internal OID.
§Example
use hyperdb_api_core::types::SqlType;
let int_type = SqlType::int();
assert_eq!(int_type.to_string(), "INTEGER");
let numeric_type = SqlType::numeric(18, 2);
assert_eq!(numeric_type.to_string(), "NUMERIC(18, 2)");Variants§
Bool
Boolean type.
BigInt
64-bit integer (BIGINT).
SmallInt
16-bit integer (SMALLINT).
Int
32-bit integer (INT).
Numeric
Numeric/decimal type with precision and scale.
Fields
Double
Double precision floating point.
Float
Single precision floating point.
Oid
Object identifier.
ByteA
Binary data (BYTEA).
Text
Variable-length text.
Varchar
Variable-length character string with max length.
Char
Fixed-length character string.
Json
JSON data.
Date
Date (year, month, day).
Interval
Time interval.
Time
Time of day.
Timestamp
Timestamp without timezone.
TimestampTz
Timestamp with timezone.
Geography
Geography/geometric data.
Unsupported
Unsupported type.
Implementations§
Source§impl SqlType
impl SqlType
Sourcepub fn bool() -> SqlType
pub fn bool() -> SqlType
Creates a Bool type.
§Example
use hyperdb_api_core::types::SqlType;
let t = SqlType::bool();
assert_eq!(t.to_string(), "BOOLEAN");Sourcepub fn big_int() -> SqlType
pub fn big_int() -> SqlType
Creates a BigInt type.
§Example
use hyperdb_api_core::types::SqlType;
let t = SqlType::big_int();
assert_eq!(t.to_string(), "BIGINT");Sourcepub fn small_int() -> SqlType
pub fn small_int() -> SqlType
Creates a SmallInt type.
§Example
use hyperdb_api_core::types::SqlType;
let t = SqlType::small_int();
assert_eq!(t.to_string(), "SMALLINT");Sourcepub fn int() -> SqlType
pub fn int() -> SqlType
Creates an Int type.
§Example
use hyperdb_api_core::types::SqlType;
let t = SqlType::int();
assert_eq!(t.to_string(), "INTEGER");Sourcepub fn numeric(precision: u32, scale: u32) -> SqlType
pub fn numeric(precision: u32, scale: u32) -> SqlType
Creates a Numeric type with the given precision and scale.
§Arguments
precision- Total number of digits (1-38)scale- Number of digits after decimal point (0-precision)
§Panics
Panics if precision is not in 1..=38 or scale > precision.
§Example
use hyperdb_api_core::types::SqlType;
let t = SqlType::numeric(18, 2);
assert_eq!(t.to_string(), "NUMERIC(18, 2)");Sourcepub fn double() -> SqlType
pub fn double() -> SqlType
Creates a Double type.
§Example
use hyperdb_api_core::types::SqlType;
let t = SqlType::double();
assert_eq!(t.to_string(), "DOUBLE PRECISION");Sourcepub fn float() -> SqlType
pub fn float() -> SqlType
Creates a Float type.
§Example
use hyperdb_api_core::types::SqlType;
let t = SqlType::float();
assert_eq!(t.to_string(), "REAL");Sourcepub fn text() -> SqlType
pub fn text() -> SqlType
Creates a Text type.
§Example
use hyperdb_api_core::types::SqlType;
let t = SqlType::text();
assert_eq!(t.to_string(), "TEXT");Sourcepub fn varchar(max_length: Option<u32>) -> SqlType
pub fn varchar(max_length: Option<u32>) -> SqlType
Creates a Varchar type with optional max length.
§Example
use hyperdb_api_core::types::SqlType;
let t = SqlType::varchar(Some(255));
assert_eq!(t.to_string(), "VARCHAR(255)");Sourcepub fn char(length: u32) -> SqlType
pub fn char(length: u32) -> SqlType
Creates a Char type with the given length.
§Example
use hyperdb_api_core::types::SqlType;
let t = SqlType::char(10);
assert_eq!(t.to_string(), "CHAR(10)");Sourcepub fn date() -> SqlType
pub fn date() -> SqlType
Creates a Date type.
§Example
use hyperdb_api_core::types::SqlType;
let t = SqlType::date();
assert_eq!(t.to_string(), "DATE");Sourcepub fn time() -> SqlType
pub fn time() -> SqlType
Creates a Time type.
§Example
use hyperdb_api_core::types::SqlType;
let t = SqlType::time();
assert_eq!(t.to_string(), "TIME");Sourcepub fn timestamp() -> SqlType
pub fn timestamp() -> SqlType
Creates a Timestamp type.
§Example
use hyperdb_api_core::types::SqlType;
let t = SqlType::timestamp();
assert_eq!(t.to_string(), "TIMESTAMP");Sourcepub fn timestamp_tz() -> SqlType
pub fn timestamp_tz() -> SqlType
Creates a TimestampTz type.
§Example
use hyperdb_api_core::types::SqlType;
let t = SqlType::timestamp_tz();
assert_eq!(t.to_string(), "TIMESTAMPTZ");Sourcepub fn bytes() -> SqlType
pub fn bytes() -> SqlType
Creates a ByteA (binary) type.
§Example
use hyperdb_api_core::types::SqlType;
let t = SqlType::bytes();
assert_eq!(t.to_string(), "BYTEA");Sourcepub fn json() -> SqlType
pub fn json() -> SqlType
Creates a Json type.
§Example
use hyperdb_api_core::types::SqlType;
let t = SqlType::json();
assert_eq!(t.to_string(), "JSON");Sourcepub fn geography() -> SqlType
pub fn geography() -> SqlType
Creates a Geography type.
Note: tabgeography() is the preferred method name to match C++ and Java APIs.
Sourcepub fn tabgeography() -> SqlType
pub fn tabgeography() -> SqlType
Creates a TabGeography type (Tableau geography).
This is the preferred method for creating geography columns, matching the C++ and Java API naming conventions.
§Example
use hyperdb_api_core::types::SqlType;
let t = SqlType::tabgeography();
assert_eq!(t.to_string(), "GEOGRAPHY");Sourcepub fn internal_oid(&self) -> u32
pub fn internal_oid(&self) -> u32
Returns the internal OID for this SQL type.
The internal OID is used by Hyper’s protocol layer for type identification.
§Example
use hyperdb_api_core::types::SqlType;
let t = SqlType::int();
assert_eq!(t.internal_oid(), 23);Sourcepub fn precision(&self) -> Option<u32>
pub fn precision(&self) -> Option<u32>
Returns the precision for Numeric types, or None for other types.
Sourcepub fn scale(&self) -> Option<u32>
pub fn scale(&self) -> Option<u32>
Returns the scale for Numeric types, or None for other types.
Sourcepub fn max_length(&self) -> Option<u32>
pub fn max_length(&self) -> Option<u32>
Returns the max length for Varchar/Char types, or None for other types.
Sourcepub fn from_oid(oid: u32) -> SqlType
pub fn from_oid(oid: u32) -> SqlType
Creates a SqlType from an OID.
§Example
use hyperdb_api_core::types::SqlType;
let t = SqlType::from_oid(23);
assert_eq!(t, SqlType::Int);Sourcepub fn from_oid_and_modifier(oid: u32, modifier: i32) -> SqlType
pub fn from_oid_and_modifier(oid: u32, modifier: i32) -> SqlType
Creates a SqlType from an OID and type modifier.
Type modifiers encode additional information like precision/scale for numeric types or max length for varchar types.
For NUMERIC types, the modifier format is: ((precision << 16) | scale) + 4.
Valid modifiers are >= 4 (since minimum valid precision is 1 and scale is 0).
Malformed modifiers (values 1-3, or values producing precision > 38 or scale > precision)
are treated as unspecified (precision=0, scale=0).
§Panics
Does not panic in practice. The NUMERIC, VARCHAR, and CHAR branches
each convert modifier - 4 to u32 via try_from().expect(...)
guarded by a modifier < 4 check, so the subtraction is always
non-negative.
Sourcepub fn is_numeric(&self) -> bool
pub fn is_numeric(&self) -> bool
Returns true if this type is a numeric type (can store numbers).
Sourcepub fn is_temporal(&self) -> bool
pub fn is_temporal(&self) -> bool
Returns true if this type is a temporal type.
Sourcepub fn is_unsupported(&self) -> bool
pub fn is_unsupported(&self) -> bool
Returns true if this is an unsupported type.
Trait Implementations§
impl Copy for SqlType
impl Eq for SqlType
impl StructuralPartialEq for SqlType
Auto Trait Implementations§
impl Freeze for SqlType
impl RefUnwindSafe for SqlType
impl Send for SqlType
impl Sync for SqlType
impl Unpin for SqlType
impl UnsafeUnpin for SqlType
impl UnwindSafe for SqlType
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<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
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>
T in a tonic::Request