use crate::edge::EdgeRelation;
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct VerbDef {
pub name: &'static str,
pub description: &'static str,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum EndpointKind {
NoteOfKind(&'static str),
EntityOfKind(&'static str),
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct EdgeEndpointRule {
pub relation: EdgeRelation,
pub source: EndpointKind,
pub target: EndpointKind,
}
pub trait Pack {
const NAME: &'static str;
const NOTE_KINDS: &'static [&'static str];
const ENTITY_KINDS: &'static [&'static str];
const VERBS: &'static [VerbDef];
const EDGE_RULES: &'static [EdgeEndpointRule] = &[];
const REQUIRES: &'static [&'static str] = &[];
}
#[cfg(test)]
mod tests {
use super::*;
struct TestPack;
impl Pack for TestPack {
const NAME: &'static str = "test";
const NOTE_KINDS: &'static [&'static str] = &["memo"];
const ENTITY_KINDS: &'static [&'static str] = &["widget"];
const VERBS: &'static [VerbDef] = &[VerbDef {
name: "do_thing",
description: "does a thing",
}];
}
#[test]
fn pack_trait_compiles() {
assert_eq!(TestPack::NAME, "test");
assert_eq!(TestPack::NOTE_KINDS, &["memo"]);
assert_eq!(TestPack::ENTITY_KINDS, &["widget"]);
assert_eq!(TestPack::VERBS.len(), 1);
assert_eq!(TestPack::VERBS[0].name, "do_thing");
}
}