pub type Result = core::result::Result; pub type Error = Box; // For early dev. use modql::field::{Fields, HasFields}; #[derive(Debug, Default, Fields)] #[modql(rel = "todo_table")] pub struct Todo { pub id: i64, #[field(rel = "special_todo_table", name = "special_title_col")] pub title: String, #[field(name = "description")] pub desc: Option, #[field(skip)] pub other: Option, } #[test] fn test_struct_field_names() -> Result<()> { assert_eq!(Todo::field_names(), &["id", "special_title_col", "description"]); Ok(()) } #[test] fn test_struct_field_metas() -> Result<()> { // -- Exec let field_refs = Todo::field_metas(); // -- Check let names: Vec<&'static str> = field_refs.iter().map(|&meta| meta.name()).collect(); let rels: Vec> = field_refs.iter().map(|fr| fr.rel).collect(); assert_eq!(names, &["id", "special_title_col", "description"]); assert_eq!( rels, &[Some("todo_table"), Some("special_todo_table"), Some("todo_table")] ); Ok(()) }