use serde::de::DeserializeOwned;
use serde::Serialize;
pub trait Row: DeserializeOwned + Serialize + Send + Sync + 'static {
const TABLE: &'static str;
const COLUMNS: &'static [&'static str] = &[];
const SCHEMA: Option<&'static str> = None;
}
#[cfg(test)]
mod tests {
use super::*;
use serde::Deserialize;
#[derive(Debug, Clone, Serialize, Deserialize)]
struct Country {
id: i64,
name: String,
}
impl Row for Country {
const TABLE: &'static str = "countries";
const COLUMNS: &'static [&'static str] = &["id", "name"];
}
#[test]
fn row_metadata_is_reachable() {
assert_eq!(Country::TABLE, "countries");
assert_eq!(Country::COLUMNS, &["id", "name"]);
assert_eq!(Country::SCHEMA, None);
}
}