use super::SourceRegistry;
use crate::pipes::PipeRouter;
#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[cfg_attr(
feature = "serde",
derive(serde::Serialize, serde::Deserialize),
serde(rename_all = "snake_case")
)]
#[repr(C)]
pub struct SourceManager {
pub(crate) registry: SourceRegistry,
pub(crate) router: PipeRouter,
}
impl SourceManager {
pub const fn new() -> Self {
Self {
registry: SourceRegistry::new(),
router: PipeRouter::new(),
}
}
pub fn from_registry(registry: SourceRegistry) -> Self {
Self {
registry,
router: PipeRouter::default(),
}
}
pub fn from_router(router: PipeRouter) -> Self {
Self {
registry: SourceRegistry::default(),
router,
}
}
pub const fn registry(&self) -> &SourceRegistry {
&self.registry
}
pub const fn registry_mut(&mut self) -> &mut SourceRegistry {
&mut self.registry
}
pub const fn router(&self) -> &PipeRouter {
&self.router
}
pub fn router_mut(&mut self) -> &mut PipeRouter {
&mut self.router
}
pub fn set_registry(&mut self, registry: SourceRegistry) -> &mut Self {
self.registry = registry;
self
}
pub const fn with_registry(self, registry: SourceRegistry) -> Self {
Self { registry, ..self }
}
pub const fn with_router(self, router: PipeRouter) -> Self {
Self { router, ..self }
}
}