use std::sync::Arc;
use crate::expr::{Base, Expr};
use crate::val::{Object, Value};
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub enum InfoStatement {
Root(bool, Option<Expr>),
Ns(bool, Option<Expr>),
Db(bool, Option<Expr>),
Tb(Expr, bool, Option<Expr>),
User(Expr, Option<Base>, bool),
Index(Expr, Expr, bool),
}
pub trait InfoStructure {
fn structure(self) -> Value;
}
impl InfoStructure for surrealdb_cnf::DynamicConfiguration {
fn structure(self) -> Value {
let object = map! {
"QUERY_TIMEOUT" => match self.get_query_timeout() {
None => Value::None,
Some(d) => d.into(),
}
};
Value::Object(Object::from(object))
}
}
pub fn process<T>(a: &Arc<[T]>) -> Value
where
T: InfoStructure + Clone,
{
Value::Array(a.iter().cloned().map(InfoStructure::structure).collect())
}