Skip to main content

SqlType

Enum SqlType 

Source
pub enum SqlType {
Show 20 variants Bool, BigInt, SmallInt, Int, Numeric { precision: u32, scale: u32, }, Double, Float, Oid, ByteA, Text, Varchar { max_length: Option<u32>, }, Char { length: u32, }, Json, Date, Interval, Time, Timestamp, TimestampTz, Geography, Unsupported,
}
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

§precision: u32

Total number of digits (1-38).

§scale: u32

Number of digits after decimal point (0-precision).

§

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.

Fields

§max_length: Option<u32>

Maximum length, or None for unlimited.

§

Char

Fixed-length character string.

Fields

§length: u32

Fixed length.

§

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

Source

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");
Source

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");
Source

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");
Source

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");
Source

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)");
Source

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");
Source

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");
Source

pub fn oid() -> SqlType

Creates an Oid type.

Source

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");
Source

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)");
Source

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)");
Source

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");
Source

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");
Source

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");
Source

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");
Source

pub fn interval() -> SqlType

Creates an Interval type.

Source

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");
Source

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");
Source

pub fn geography() -> SqlType

Creates a Geography type.

Note: tabgeography() is the preferred method name to match C++ and Java APIs.

Source

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");
Source

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);
Source

pub fn precision(&self) -> Option<u32>

Returns the precision for Numeric types, or None for other types.

Source

pub fn scale(&self) -> Option<u32>

Returns the scale for Numeric types, or None for other types.

Source

pub fn max_length(&self) -> Option<u32>

Returns the max length for Varchar/Char types, or None for other types.

Source

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);
Source

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.

Source

pub fn is_numeric(&self) -> bool

Returns true if this type is a numeric type (can store numbers).

Source

pub fn is_string(&self) -> bool

Returns true if this type is a string type.

Source

pub fn is_temporal(&self) -> bool

Returns true if this type is a temporal type.

Source

pub fn is_unsupported(&self) -> bool

Returns true if this is an unsupported type.

Trait Implementations§

Source§

impl Clone for SqlType

Source§

fn clone(&self) -> SqlType

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SqlType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for SqlType

Source§

fn default() -> SqlType

Returns the “default value” for a type. Read more
Source§

impl Display for SqlType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl PartialEq for SqlType

Source§

fn eq(&self, other: &SqlType) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for SqlType

Source§

impl Eq for SqlType

Source§

impl StructuralPartialEq for SqlType

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,