diff --git a/core/src/lib.rs b/core/src/lib.rs index 73e28858..4fe71fd2 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -188,6 +188,50 @@ impl TypedValue { } } +// We don't do From or From 'cos it's ambiguous. + +impl From for TypedValue { + fn from(value: bool) -> TypedValue { + TypedValue::Boolean(value) + } +} + +impl From> for TypedValue { + fn from(value: DateTime) -> TypedValue { + TypedValue::Instant(value) + } +} + +impl From for TypedValue { + fn from(value: Uuid) -> TypedValue { + TypedValue::Uuid(value) + } +} + +impl From for TypedValue { + fn from(value: String) -> TypedValue { + TypedValue::String(Rc::new(value)) + } +} + +impl From for TypedValue { + fn from(value: NamespacedKeyword) -> TypedValue { + TypedValue::Keyword(Rc::new(value)) + } +} + +impl From for TypedValue { + fn from(value: u32) -> TypedValue { + TypedValue::Long(value as i64) + } +} + +impl From for TypedValue { + fn from(value: i32) -> TypedValue { + TypedValue::Long(value as i64) + } +} + // Put this here rather than in `db` simply because it's widely needed. pub trait SQLValueType { fn value_type_tag(&self) -> i32;