pub enum Value<'c> {
Varchar(&'c str),
Bool(bool),
Tinyint(i8),
UnsignedTinyint(u8),
Smallint(i16),
UnsignedSmallint(u16),
Int(i32),
UnsignedInt(u32),
Bigint(i64),
UnsignedBigint(u64),
}
Expand description
Enum representing common SQL-datatypes
Variants§
Varchar(&'c str)
Bool(bool)
Tinyint(i8)
UnsignedTinyint(u8)
Smallint(i16)
UnsignedSmallint(u16)
Int(i32)
UnsignedInt(u32)
Bigint(i64)
UnsignedBigint(u64)
Implementations§
Source§impl<'c> Value<'c>
impl<'c> Value<'c>
Sourcepub fn as_string(&self) -> String
pub fn as_string(&self) -> String
Convert the Value to a String
§Example
use query_builder::Value;
// Put single quotes around the varchar to not conflict with e.g. MySQL when inserting data
let v = Value::Varchar("steven");
assert_eq!(v.as_string(), "'steven'");
// Bools are written in caps to make them stand out in queries
let v = Value::Bool(true);
assert_eq!(v.as_string(), "TRUE");
// applies to all numeric Values
let v = Value::Int(42);
assert_eq!(v.as_string(), "42");
Trait Implementations§
Source§impl<'c> Ord for Value<'c>
impl<'c> Ord for Value<'c>
Source§impl<'c> PartialOrd for Value<'c>
impl<'c> PartialOrd for Value<'c>
impl<'c> Eq for Value<'c>
impl<'c> StructuralPartialEq for Value<'c>
Auto Trait Implementations§
impl<'c> Freeze for Value<'c>
impl<'c> RefUnwindSafe for Value<'c>
impl<'c> Send for Value<'c>
impl<'c> Sync for Value<'c>
impl<'c> Unpin for Value<'c>
impl<'c> UnwindSafe for Value<'c>
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