use std::{collections::HashSet, fmt::Debug, marker::PhantomData};
use frunk_core::HList;
use manas_access_control::layered_repo::AccessControlledRepo;
use manas_http::representation::impl_::binary::BinaryRepresentation;
use manas_repo_layers::{
dconneging::{
conneg_layer::{
impl_::binary_rdf_doc_converting::BinaryRdfDocContentNegotiationLayer,
DerivedContentNegotiationLayer,
},
DerivedContentNegotiatingRepo,
},
patching::{
patcher::impl_::{
binary_rdf_doc_patcher::BinaryRdfDocPatcher,
solid_insert_delete_patcher::SolidInsertDeletePatcher,
},
PatchingRepo,
},
validating::{
update_validator::impl_::{
aux_protecting::AuxProtectingRepUpdateValidator,
container_protecting::ContainerProtectingRepUpdateValidator,
multi::MultiRepUpdateValidator,
},
ValidatingRepo,
},
};
use manas_repo_opendal::{
object_store::{
backend::ODRObjectStoreBackend,
object_space::{
assoc::mapping_scheme::impl_::default::DefaultAssocMappingScheme, ODRObjectSpaceSetup,
},
setup::impl_::BasicODRObjectStoreSetup,
},
service::resource_operator::reader::ODRResourceReader,
setup::{aux_rep_policy::impl_::default::DefaultODRAuxResourcePolicy, ODRSetup},
OpendalRepo,
};
use manas_semslot::scheme::impl_::hierarchical::{
aux::impl_::default::DefaultAuxLinkEncodingScheme, HierarchicalSemanticSlotEncodingScheme,
};
use rdf_utils::model::quad::ArcQuad;
use crate::space::RcpStorageSpace;
#[derive(Debug, Clone)]
pub struct RcpObjectSpaceSetup {}
impl ODRObjectSpaceSetup for RcpObjectSpaceSetup {
type AssocStSpace = RcpStorageSpace;
type AssocStSemSlotES =
HierarchicalSemanticSlotEncodingScheme<RcpStorageSpace, DefaultAuxLinkEncodingScheme>;
type AssocMappingScheme =
DefaultAssocMappingScheme<RcpStorageSpace, DefaultAuxLinkEncodingScheme>;
}
pub type RcpObjectStoreSetup<Backend> = BasicODRObjectStoreSetup<RcpObjectSpaceSetup, Backend>;
pub struct RcpBaseRepoSetup<Backend> {
_phantom: PhantomData<fn(Backend)>,
}
impl<Backend> Debug for RcpBaseRepoSetup<Backend> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("RcpBaseRepoSetup").finish()
}
}
impl<Backend> Clone for RcpBaseRepoSetup<Backend> {
fn clone(&self) -> Self {
Self {
_phantom: self._phantom,
}
}
}
impl<Backend: ODRObjectStoreBackend> ODRSetup for RcpBaseRepoSetup<Backend> {
type StSpace = RcpStorageSpace;
type ObjectStoreSetup = RcpObjectStoreSetup<Backend>;
type AuxResourcePolicy = DefaultODRAuxResourcePolicy<RcpStorageSpace>;
}
pub type RcpBaseRepo<Backend> = OpendalRepo<RcpBaseRepoSetup<Backend>>;
pub type RcpConnegingRepo<Backend, CNL> = DerivedContentNegotiatingRepo<RcpBaseRepo<Backend>, CNL>;
pub type RcpRepValidator<Backend, CNL> = MultiRepUpdateValidator<
RcpConnegingRepo<Backend, CNL>,
HList!(
ContainerProtectingRepUpdateValidator<RcpConnegingRepo<Backend, CNL>, BinaryRepresentation>,
AuxProtectingRepUpdateValidator<RcpConnegingRepo<Backend, CNL>, BinaryRepresentation>,
),
>;
pub type RcpRepPatcher = BinaryRdfDocPatcher<
RcpStorageSpace,
SolidInsertDeletePatcher<RcpStorageSpace, HashSet<ArcQuad>>,
HashSet<ArcQuad>,
>;
pub type RcpRepo<Backend, CNL, PEP> = AccessControlledRepo<
PatchingRepo<
ValidatingRepo<RcpConnegingRepo<Backend, CNL>, RcpRepValidator<Backend, CNL>>,
RcpRepPatcher,
>,
PEP,
>;
pub type RcpRdfSourceCNL<Backend> = BinaryRdfDocContentNegotiationLayer<
RcpBaseRepo<Backend>,
ODRResourceReader<RcpBaseRepoSetup<Backend>>,
>;
pub type RcpCNLConfig<CNL, Backend> = <CNL as DerivedContentNegotiationLayer<
RcpBaseRepo<Backend>,
BinaryRepresentation,
ODRResourceReader<RcpBaseRepoSetup<Backend>>,
>>::Config;