pub trait ReadableMetadata {
// Required methods
fn rust_type(&self) -> &'static str;
fn db_type(&self) -> dyn TypeInfo;
fn get_name(&self) -> String;
fn get_native_type_metadata(&self);
// Provided methods
fn get_nullability(&self) -> Nullability { ... }
fn get_precision(&self) -> Option<u64> { ... }
fn get_scale(&self) -> Option<u64> { ... }
}
Expand description
Represents the metadata for readable object, for example a column of the results returned from a query or [OUT] parameter as result of running a stored procedure. The implementation of all methods except [get_name()] is optional for drivers. Metadata is optionally available as by-product of statement execution on a best-effort basis.
Required Methods§
fn rust_type(&self) -> &'static str
Sourcefn get_name(&self) -> String
fn get_name(&self) -> String
Returns the name.
The name does not necessarily reflect the names how they are in the underlying tables but rather how results are represented (e.g. aliased) in the result.
Sourcefn get_native_type_metadata(&self)
fn get_native_type_metadata(&self)
Returns the native type descriptor that potentially exposes more metadata. Drivers should implement this method if they can expose a driver-specific type metadata object exposing additional information.
The default implementation returns None.
Provided Methods§
Sourcefn get_nullability(&self) -> Nullability
fn get_nullability(&self) -> Nullability
Returns the nullability of values. Implementation of this method is optional. The default implementation returns Nullability::Unknown.
Sourcefn get_precision(&self) -> Option<u64>
fn get_precision(&self) -> Option<u64>
Returns the precision.
- For numeric data, this is the maximum precision.
- For character data, this is the length in characters.
- For datetime data types, this is the length in bytes required to represent the value (assuming the
- maximum allowed precision of the fractional seconds component).
- For binary data, this is the length in bytes.
- Returns {@code null} for data types where data type size is not applicable or if the precision cannot be provided.
Implementation of this method is optional. The default implementation returns None.
Sourcefn get_scale(&self) -> Option<u64>
fn get_scale(&self) -> Option<u64>
Returns the scale.
- This is the number of digits to right of the decimal point.
- Returns {@code null} for data types where the scale is not applicable or if the scale cannot be provided.
Implementation of this method is optional. The default implementation returns None.
the scale or None if the scale is not available.