use std::fmt;
pub mod error;
pub mod traits;
pub use error::{AgentDbError, Result};
pub use traits::{AgentDB, Capabilities, DefaultCapabilities, Row, Transaction, QueryResult, ScanResult};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum BackendFamily {
Sql,
Kv,
Graph,
}
impl fmt::Display for BackendFamily {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
BackendFamily::Sql => write!(f, "SQL"),
BackendFamily::Kv => write!(f, "KeyValue"),
BackendFamily::Graph => write!(f, "Graph"),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Value(Vec<u8>);
impl Value {
pub fn new(data: Vec<u8>) -> Self {
Self(data)
}
pub fn from_slice(data: &[u8]) -> Self {
Self(data.to_vec())
}
pub fn as_bytes(&self) -> &[u8] {
&self.0
}
pub fn into_bytes(self) -> Vec<u8> {
self.0
}
}
impl From<Vec<u8>> for Value {
fn from(data: Vec<u8>) -> Self {
Self(data)
}
}
impl From<&[u8]> for Value {
fn from(data: &[u8]) -> Self {
Self(data.to_vec())
}
}
impl AsRef<[u8]> for Value {
fn as_ref(&self) -> &[u8] {
&self.0
}
}