|
@@ -1,8 +1,9 @@
|
|
|
-use microrm::{
|
|
|
+use crate::{
|
|
|
prelude::*,
|
|
|
schema::{
|
|
|
datum::{ConcreteDatumList, Datum, DatumDiscriminator, DatumDiscriminatorRef},
|
|
|
- entity::{Entity, EntityID, EntityPartList, EntityPartVisitor, EntityVisitor},
|
|
|
+ entity::{Entity, EntityID, EntityPart, EntityPartList, EntityPartVisitor, EntityVisitor},
|
|
|
+ relation::{Relation, RelationDomain, RelationMap, RelationRange},
|
|
|
},
|
|
|
};
|
|
|
|
|
@@ -21,7 +22,7 @@ fn add_keys<E: Entity, IC: InterfaceCustomization>(
|
|
|
);
|
|
|
impl<'a, IC: InterfaceCustomization, E: Entity> EntityPartVisitor for UVisitor<'a, IC, E> {
|
|
|
type Entity = E;
|
|
|
- fn visit<EP: microrm::schema::entity::EntityPart>(&mut self) {
|
|
|
+ fn visit<EP: EntityPart>(&mut self) {
|
|
|
if !IC::has_value_for(EP::Entity::entity_name(), EP::part_name(), self.1) {
|
|
|
let arg = clap::Arg::new(EP::part_name())
|
|
|
.required(true)
|
|
@@ -52,7 +53,7 @@ fn collect_keys<E: Entity, IC: InterfaceCustomization>(
|
|
|
);
|
|
|
impl<'a, IC: InterfaceCustomization, E: Entity> EntityPartVisitor for UVisitor<'a, IC, E> {
|
|
|
type Entity = E;
|
|
|
- fn visit<EP: microrm::schema::entity::EntityPart>(&mut self) {
|
|
|
+ fn visit<EP: EntityPart>(&mut self) {
|
|
|
if !IC::has_value_for(EP::Entity::entity_name(), EP::part_name(), self.2) {
|
|
|
self.1.push(EntityKey::UserInput(
|
|
|
self.0
|
|
@@ -138,7 +139,7 @@ impl<O: CLIObject> InterfaceVerb<O> {
|
|
|
}
|
|
|
impl<'l, IC: InterfaceCustomization, E: Entity> EntityPartVisitor for RelationFinder<'l, IC, E> {
|
|
|
type Entity = E;
|
|
|
- fn visit<EP: microrm::schema::entity::EntityPart>(&mut self) {
|
|
|
+ fn visit<EP: EntityPart>(&mut self) {
|
|
|
if EP::part_name() != self.subcommand {
|
|
|
return;
|
|
|
}
|
|
@@ -258,7 +259,7 @@ impl<'l, Error: CLIError, OE: Entity> Attacher<'l, Error, OE> {
|
|
|
|
|
|
impl<'l, Error: CLIError, E: Entity> EntityPartVisitor for Attacher<'l, Error, E> {
|
|
|
type Entity = E;
|
|
|
- fn visit_datum<EP: microrm::schema::entity::EntityPart>(&mut self, datum: &EP::Datum) {
|
|
|
+ fn visit_datum<EP: EntityPart>(&mut self, datum: &EP::Datum) {
|
|
|
if EP::part_name() != self.relation {
|
|
|
return;
|
|
|
}
|
|
@@ -281,16 +282,10 @@ impl<'l, Error: CLIError, OE: Entity> DatumDiscriminatorRef for Attacher<'l, Err
|
|
|
fn visit_relation_map<E: Entity>(&mut self, map: &RelationMap<E>) {
|
|
|
self.do_operation(map);
|
|
|
}
|
|
|
- fn visit_relation_range<R: microrm::schema::Relation>(
|
|
|
- &mut self,
|
|
|
- map: µrm::schema::RelationRange<R>,
|
|
|
- ) {
|
|
|
+ fn visit_relation_range<R: Relation>(&mut self, map: &RelationRange<R>) {
|
|
|
self.do_operation(map);
|
|
|
}
|
|
|
- fn visit_relation_domain<R: microrm::schema::Relation>(
|
|
|
- &mut self,
|
|
|
- map: µrm::schema::RelationDomain<R>,
|
|
|
- ) {
|
|
|
+ fn visit_relation_domain<R: Relation>(&mut self, map: &RelationDomain<R>) {
|
|
|
self.do_operation(map);
|
|
|
}
|
|
|
}
|
|
@@ -464,10 +459,7 @@ impl<O: CLIObject, IC: InterfaceCustomization> ClapInterface<O, IC> {
|
|
|
struct RelationFieldWalker<E: Entity>(std::marker::PhantomData<E>);
|
|
|
impl<E: Entity> EntityPartVisitor for RelationFieldWalker<E> {
|
|
|
type Entity = E;
|
|
|
- fn visit_datum<EP: microrm::schema::entity::EntityPart>(
|
|
|
- &mut self,
|
|
|
- datum: &EP::Datum,
|
|
|
- ) {
|
|
|
+ fn visit_datum<EP: EntityPart>(&mut self, datum: &EP::Datum) {
|
|
|
struct Discriminator(&'static str);
|
|
|
|
|
|
impl DatumDiscriminatorRef for Discriminator {
|
|
@@ -483,15 +475,15 @@ impl<O: CLIObject, IC: InterfaceCustomization> ClapInterface<O, IC> {
|
|
|
fn visit_relation_map<E: Entity>(&mut self, amap: &RelationMap<E>) {
|
|
|
inspect_ai(self.0, amap);
|
|
|
}
|
|
|
- fn visit_relation_domain<R: microrm::schema::Relation>(
|
|
|
+ fn visit_relation_domain<R: Relation>(
|
|
|
&mut self,
|
|
|
- adomain: µrm::schema::RelationDomain<R>,
|
|
|
+ adomain: &RelationDomain<R>,
|
|
|
) {
|
|
|
inspect_ai(self.0, adomain);
|
|
|
}
|
|
|
- fn visit_relation_range<R: microrm::schema::Relation>(
|
|
|
+ fn visit_relation_range<R: Relation>(
|
|
|
&mut self,
|
|
|
- arange: µrm::schema::RelationRange<R>,
|
|
|
+ arange: &RelationRange<R>,
|
|
|
) {
|
|
|
inspect_ai(self.0, arange);
|
|
|
}
|
|
@@ -519,7 +511,7 @@ impl<O: CLIObject, IC: InterfaceCustomization> ClapInterface<O, IC> {
|
|
|
);
|
|
|
impl<'l, IC: InterfaceCustomization, E: Entity> EntityPartVisitor for PartVisitor<'l, IC, E> {
|
|
|
type Entity = E;
|
|
|
- fn visit<EP: microrm::schema::entity::EntityPart>(&mut self) {
|
|
|
+ fn visit<EP: EntityPart>(&mut self) {
|
|
|
struct Discriminator<'l, IC: InterfaceCustomization>(
|
|
|
&'l mut Vec<clap::Command>,
|
|
|
&'static str,
|
|
@@ -539,13 +531,13 @@ impl<O: CLIObject, IC: InterfaceCustomization> ClapInterface<O, IC> {
|
|
|
ValueRole::AttachmentTarget,
|
|
|
));
|
|
|
}
|
|
|
- fn visit_relation_domain<R: microrm::schema::Relation>(&mut self) {
|
|
|
+ fn visit_relation_domain<R: Relation>(&mut self) {
|
|
|
self.0.push(add_keys::<R::Range, IC>(
|
|
|
clap::Command::new(self.1),
|
|
|
ValueRole::AttachmentTarget,
|
|
|
));
|
|
|
}
|
|
|
- fn visit_relation_range<R: microrm::schema::Relation>(&mut self) {
|
|
|
+ fn visit_relation_range<R: Relation>(&mut self) {
|
|
|
self.0.push(add_keys::<R::Domain, IC>(
|
|
|
clap::Command::new(self.1),
|
|
|
ValueRole::AttachmentTarget,
|