Pre: define Display for ValueType.
This commit is contained in:
parent
8ddbc834ae
commit
01af45ab3f
1 changed files with 23 additions and 8 deletions
|
@ -17,6 +17,7 @@ extern crate edn;
|
||||||
pub mod values;
|
pub mod values;
|
||||||
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
use std::fmt;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use self::ordered_float::OrderedFloat;
|
use self::ordered_float::OrderedFloat;
|
||||||
use self::edn::NamespacedKeyword;
|
use self::edn::NamespacedKeyword;
|
||||||
|
@ -44,19 +45,33 @@ pub enum ValueType {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ValueType {
|
impl ValueType {
|
||||||
pub fn to_edn_value(&self) -> edn::Value {
|
pub fn to_edn_value(self) -> edn::Value {
|
||||||
match self {
|
match self {
|
||||||
&ValueType::Ref => values::DB_TYPE_REF.clone(),
|
ValueType::Ref => values::DB_TYPE_REF.clone(),
|
||||||
&ValueType::Boolean => values::DB_TYPE_BOOLEAN.clone(),
|
ValueType::Boolean => values::DB_TYPE_BOOLEAN.clone(),
|
||||||
&ValueType::Instant => values::DB_TYPE_INSTANT.clone(),
|
ValueType::Instant => values::DB_TYPE_INSTANT.clone(),
|
||||||
&ValueType::Long => values::DB_TYPE_LONG.clone(),
|
ValueType::Long => values::DB_TYPE_LONG.clone(),
|
||||||
&ValueType::Double => values::DB_TYPE_DOUBLE.clone(),
|
ValueType::Double => values::DB_TYPE_DOUBLE.clone(),
|
||||||
&ValueType::String => values::DB_TYPE_STRING.clone(),
|
ValueType::String => values::DB_TYPE_STRING.clone(),
|
||||||
&ValueType::Keyword => values::DB_TYPE_KEYWORD.clone(),
|
ValueType::Keyword => values::DB_TYPE_KEYWORD.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for ValueType {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
write!(f, "{}", match *self {
|
||||||
|
ValueType::Ref => "db.type/ref",
|
||||||
|
ValueType::Boolean => "db.type/boolean",
|
||||||
|
ValueType::Instant => "db.type/instant",
|
||||||
|
ValueType::Long => "db.type/long",
|
||||||
|
ValueType::Double => "db.type/double",
|
||||||
|
ValueType::String => "db.type/string",
|
||||||
|
ValueType::Keyword => "db.type/keyword",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Represents a Mentat value in a particular value set.
|
/// Represents a Mentat value in a particular value set.
|
||||||
// TODO: expand to include :db.type/{instant,url,uuid}.
|
// TODO: expand to include :db.type/{instant,url,uuid}.
|
||||||
// TODO: BigInt?
|
// TODO: BigInt?
|
||||||
|
|
Loading…
Reference in a new issue