pub enum GeneratedValue {
Null,
Default,
Boolean(bool),
Integer(i128),
Decimal {
minor: i128,
scale: u32,
},
Text(String),
Bytes(Vec<u8>),
DateTime(String),
Json(String),
}Expand description
A single value produced by a generator, independent of any target SQL dialect’s literal syntax.
Variants§
Null
SQL NULL.
Default
The column’s DEFAULT expression, left for the writer to emit.
Boolean(bool)
Integer(i128)
Any whole-number value, wide enough for BIGINT and beyond.
Decimal
A fixed-point number as integer minor units (e.g. cents) plus scale,
e.g. { minor: 1050, scale: 2 } for 10.50.
Text(String)
Bytes(Vec<u8>)
DateTime(String)
A pre-formatted date/time/timestamp literal.
Json(String)
A pre-serialized JSON document.
Implementations§
Source§impl GeneratedValue
impl GeneratedValue
Sourcepub fn as_boolean(&self) -> Result<bool, GenerateError>
pub fn as_boolean(&self) -> Result<bool, GenerateError>
Borrow the value as a boolean, or a GenerateError::TypeMismatch
if it isn’t one.
Sourcepub fn as_integer(&self) -> Result<i128, GenerateError>
pub fn as_integer(&self) -> Result<i128, GenerateError>
Borrow the value as an integer, or a GenerateError::TypeMismatch
if it isn’t one.
Sourcepub fn as_decimal(&self) -> Result<(i128, u32), GenerateError>
pub fn as_decimal(&self) -> Result<(i128, u32), GenerateError>
Borrow the value as (minor units, scale), or a
GenerateError::TypeMismatch if it isn’t a decimal.
Sourcepub fn as_text(&self) -> Result<&str, GenerateError>
pub fn as_text(&self) -> Result<&str, GenerateError>
Borrow the value as text, or a GenerateError::TypeMismatch if it
isn’t one.
Sourcepub fn as_bytes(&self) -> Result<&[u8], GenerateError>
pub fn as_bytes(&self) -> Result<&[u8], GenerateError>
Borrow the value as bytes, or a GenerateError::TypeMismatch if it
isn’t one.
Sourcepub fn as_date_time(&self) -> Result<&str, GenerateError>
pub fn as_date_time(&self) -> Result<&str, GenerateError>
Borrow the value as a pre-formatted date/time literal, or a
GenerateError::TypeMismatch if it isn’t one.
Sourcepub fn as_json(&self) -> Result<&str, GenerateError>
pub fn as_json(&self) -> Result<&str, GenerateError>
Borrow the value as a pre-serialized JSON document, or a
GenerateError::TypeMismatch if it isn’t one.
Sourcepub fn compatible_with(&self, family: &SqlTypeFamily) -> bool
pub fn compatible_with(&self, family: &SqlTypeFamily) -> bool
Whether this value is a legal payload for a column of family,
independent of any particular generator. Null and Default are
legal for every family; every other variant is checked against the
one or two families it can represent (e.g. a Uuid-family column is
represented as Text, since GeneratedValue has no dedicated
UUID variant).
Trait Implementations§
Source§impl Clone for GeneratedValue
impl Clone for GeneratedValue
Source§fn clone(&self) -> GeneratedValue
fn clone(&self) -> GeneratedValue
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for GeneratedValue
impl Debug for GeneratedValue
Source§impl PartialEq for GeneratedValue
impl PartialEq for GeneratedValue
impl StructuralPartialEq for GeneratedValue
Auto Trait Implementations§
impl Freeze for GeneratedValue
impl RefUnwindSafe for GeneratedValue
impl Send for GeneratedValue
impl Sync for GeneratedValue
impl Unpin for GeneratedValue
impl UnsafeUnpin for GeneratedValue
impl UnwindSafe for GeneratedValue
Blanket Implementations§
impl<T> Allocation for T
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,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more