use gitcortex_core::error::{GitCortexError, Result};
use kuzu::Value;
pub(super) fn str_val(v: &Value) -> Result<String> {
match v {
Value::String(s) => Ok(s.clone()),
Value::Null(_) => Ok(String::new()),
other => Err(GitCortexError::Store(format!(
"expected String, got {other:?}"
))),
}
}
pub(super) fn i64_val(v: &Value) -> Result<i64> {
match v {
Value::Int64(n) => Ok(*n),
Value::Int32(n) => Ok(*n as i64),
other => Err(GitCortexError::Store(format!(
"expected Int64, got {other:?}"
))),
}
}
pub(super) fn bool_val(v: &Value) -> Result<bool> {
match v {
Value::Bool(b) => Ok(*b),
Value::Null(_) => Ok(false),
other => Err(GitCortexError::Store(format!(
"expected Bool, got {other:?}"
))),
}
}