|
@@ -504,15 +504,12 @@ pub trait IDContainer<T: Entity>: 'static + IntoIterator<Item = T::ID> {
|
|
|
|
|
|
pub trait OutputContainer<T: Entity>: 'static + IntoIterator<Item = Stored<T>> {
|
|
pub trait OutputContainer<T: Entity>: 'static + IntoIterator<Item = Stored<T>> {
|
|
type IDContainer: IDContainer<T>;
|
|
type IDContainer: IDContainer<T>;
|
|
|
|
+ type ReplacedEntity<N: Entity>: OutputContainer<N>;
|
|
fn assemble_from(conn: &Connection, stmt: StatementContext<'_>) -> DBResult<Self>
|
|
fn assemble_from(conn: &Connection, stmt: StatementContext<'_>) -> DBResult<Self>
|
|
where
|
|
where
|
|
Self: Sized;
|
|
Self: Sized;
|
|
}
|
|
}
|
|
|
|
|
|
-pub trait ContainerEntityChange<F: Entity, T: Entity>: OutputContainer<F> {
|
|
|
|
- type Container: OutputContainer<T>;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
fn assemble_id<T: Entity>(row: StatementRow) -> T::ID {
|
|
fn assemble_id<T: Entity>(row: StatementRow) -> T::ID {
|
|
<T::ID>::from_raw(row.read::<i64>(0).expect("couldn't read ID"))
|
|
<T::ID>::from_raw(row.read::<i64>(0).expect("couldn't read ID"))
|
|
}
|
|
}
|
|
@@ -534,6 +531,7 @@ impl<T: Entity> IDContainer<T> for Option<T::ID> {
|
|
|
|
|
|
impl<T: Entity> OutputContainer<T> for Option<Stored<T>> {
|
|
impl<T: Entity> OutputContainer<T> for Option<Stored<T>> {
|
|
type IDContainer = Option<T::ID>;
|
|
type IDContainer = Option<T::ID>;
|
|
|
|
+ type ReplacedEntity<N: Entity> = Option<Stored<N>>;
|
|
|
|
|
|
fn assemble_from(conn: &Connection, ctx: StatementContext<'_>) -> DBResult<Self>
|
|
fn assemble_from(conn: &Connection, ctx: StatementContext<'_>) -> DBResult<Self>
|
|
where
|
|
where
|
|
@@ -543,10 +541,6 @@ impl<T: Entity> OutputContainer<T> for Option<Stored<T>> {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-impl<F: Entity, T: Entity> ContainerEntityChange<F, T> for Option<Stored<F>> {
|
|
|
|
- type Container = Option<Stored<T>>;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
impl<T: Entity> IDContainer<T> for Vec<T::ID> {
|
|
impl<T: Entity> IDContainer<T> for Vec<T::ID> {
|
|
fn assemble_from(ctx: StatementContext<'_>) -> DBResult<Self>
|
|
fn assemble_from(ctx: StatementContext<'_>) -> DBResult<Self>
|
|
where
|
|
where
|
|
@@ -560,6 +554,7 @@ impl<T: Entity> IDContainer<T> for Vec<T::ID> {
|
|
|
|
|
|
impl<T: Entity> OutputContainer<T> for Vec<Stored<T>> {
|
|
impl<T: Entity> OutputContainer<T> for Vec<Stored<T>> {
|
|
type IDContainer = Vec<T::ID>;
|
|
type IDContainer = Vec<T::ID>;
|
|
|
|
+ type ReplacedEntity<N: Entity> = Vec<Stored<N>>;
|
|
|
|
|
|
fn assemble_from(conn: &Connection, ctx: StatementContext<'_>) -> DBResult<Self>
|
|
fn assemble_from(conn: &Connection, ctx: StatementContext<'_>) -> DBResult<Self>
|
|
where
|
|
where
|
|
@@ -571,10 +566,6 @@ impl<T: Entity> OutputContainer<T> for Vec<Stored<T>> {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-impl<F: Entity, T: Entity> ContainerEntityChange<F, T> for Vec<Stored<F>> {
|
|
|
|
- type Container = Vec<Stored<T>>;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
/// Represents a searchable context of a given entity.
|
|
/// Represents a searchable context of a given entity.
|
|
pub trait Queryable: Clone {
|
|
pub trait Queryable: Clone {
|
|
/// The entity that results from a search in this context.
|
|
/// The entity that results from a search in this context.
|
|
@@ -803,16 +794,11 @@ pub trait Queryable: Clone {
|
|
part: EP,
|
|
part: EP,
|
|
) -> impl Queryable<
|
|
) -> impl Queryable<
|
|
EntityOutput = <EP::Datum as EntityID>::Entity,
|
|
EntityOutput = <EP::Datum as EntityID>::Entity,
|
|
- OutputContainer = <Self::OutputContainer as ContainerEntityChange<
|
|
|
|
- Self::EntityOutput,
|
|
|
|
- <EP::Datum as EntityID>::Entity,
|
|
|
|
- >>::Container,
|
|
|
|
|
|
+ OutputContainer = <Self::OutputContainer as OutputContainer<Self::EntityOutput>>::ReplacedEntity<<EP::Datum as EntityID>::Entity>,
|
|
>
|
|
>
|
|
where
|
|
where
|
|
Self: Sized,
|
|
Self: Sized,
|
|
EP::Datum: EntityID,
|
|
EP::Datum: EntityID,
|
|
- Self::OutputContainer:
|
|
|
|
- ContainerEntityChange<Self::EntityOutput, <EP::Datum as EntityID>::Entity>,
|
|
|
|
{
|
|
{
|
|
components::ForeignComponent::<_, EP, Self>::new(self, part)
|
|
components::ForeignComponent::<_, EP, Self>::new(self, part)
|
|
}
|
|
}
|