use crate::{
service::service_builder::{ParallelChosen, SerialChosen},
OperationResult, Service, ServiceBuilder, ServiceRequest,
};
use bevy_app::prelude::App;
use bevy_ecs::{schedule::SystemConfigs, system::EntityCommands, world::EntityWorldMut};
pub trait ServiceTrait {
type Request: 'static + Send + Sync;
type Response: 'static + Send + Sync;
fn serve(request: ServiceRequest) -> OperationResult;
}
pub trait IntoService<M> {
type Request;
type Response;
type Streams;
type DefaultDeliver: Default;
fn insert_service_mut(self, entity_mut: &mut EntityWorldMut);
fn insert_service_commands(self, entity_commands: &mut EntityCommands);
}
pub trait IntoContinuousService<M> {
type Request;
type Response;
type Streams;
fn into_system_config(self, entity_mut: &mut EntityWorldMut) -> SystemConfigs;
}
#[allow(clippy::type_complexity)]
pub trait IntoServiceBuilder<M> {
type Service;
type Deliver;
type With;
type Also;
type Configure;
fn into_service_builder(
self,
) -> ServiceBuilder<Self::Service, Self::Deliver, Self::With, Self::Also, Self::Configure>;
}
pub trait QuickServiceBuild<M> {
type Service;
type Deliver;
fn with<With>(self, with: With) -> ServiceBuilder<Self::Service, Self::Deliver, With, (), ()>;
fn also<Also>(self, also: Also) -> ServiceBuilder<Self::Service, Self::Deliver, (), Also, ()>;
}
pub trait QuickContinuousServiceBuild<M> {
type Service;
fn with<With>(self, with: With) -> ServiceBuilder<Self::Service, (), With, (), ()>;
fn also<Also>(self, also: Also) -> ServiceBuilder<Self::Service, (), (), Also, ()>;
fn configure<Configure>(
self,
configure: Configure,
) -> ServiceBuilder<Self::Service, (), (), (), Configure>;
}
pub trait ChooseAsyncServiceDelivery<M> {
type Service;
fn serial(self) -> ServiceBuilder<Self::Service, SerialChosen, (), (), ()>;
fn parallel(self) -> ServiceBuilder<Self::Service, ParallelChosen, (), (), ()>;
}
pub trait DeliveryChoice {
fn apply_entity_mut<Request: 'static + Send + Sync>(self, entity_mut: &mut EntityWorldMut);
fn apply_entity_commands<Request: 'static + Send + Sync>(
self,
entity_commands: &mut EntityCommands,
);
}
pub trait WithEntityWorldMut {
fn apply(self, entity_mut: EntityWorldMut);
}
pub trait WithEntityCommands {
fn apply(self, entity_commands: &mut EntityCommands);
}
pub trait AlsoAdd<Request, Response, Streams> {
fn apply(self, app: &mut App, provider: Service<Request, Response, Streams>);
}
pub trait ConfigureContinuousService {
fn apply(self, config: SystemConfigs) -> SystemConfigs;
}