aboutsummaryrefslogtreecommitdiff
path: root/mingling_core/src/asset
diff options
context:
space:
mode:
Diffstat (limited to 'mingling_core/src/asset')
-rw-r--r--mingling_core/src/asset/global_resource.rs16
-rw-r--r--mingling_core/src/asset/help.rs2
-rw-r--r--mingling_core/src/asset/renderer.rs2
-rw-r--r--mingling_core/src/asset/routable.rs22
4 files changed, 29 insertions, 13 deletions
diff --git a/mingling_core/src/asset/global_resource.rs b/mingling_core/src/asset/global_resource.rs
index 651655a..29e1136 100644
--- a/mingling_core/src/asset/global_resource.rs
+++ b/mingling_core/src/asset/global_resource.rs
@@ -45,13 +45,12 @@ where
/// Internal syntax for the `&mut MyResource` syntax of #[chain], do not use directly
#[doc(hidden)]
- pub fn __modify_res_and_return_route<Res, Return>(
+ pub fn __modify_res_and_return_route<Res>(
&self,
- f: impl FnOnce(&mut Res) -> Return,
- ) -> impl Into<ChainProcess<C>>
+ f: impl FnOnce(&mut Res) -> ChainProcess<C>,
+ ) -> ChainProcess<C>
where
Res: 'static + Default + ResourceMarker + Send + Sync,
- Return: Into<ChainProcess<C>>,
{
let Ok(mut guard) = self.resources.lock() else {
let mut default_res = Res::res_default();
@@ -80,9 +79,7 @@ where
/// owned value. The caller must call [`__store_res`] to write back modifications.
#[doc(hidden)]
#[must_use]
- pub fn __extract_res_mut<Res: 'static + Default + ResourceMarker + Send + Sync>(
- &self,
- ) -> Res {
+ pub fn __extract_res_mut<Res: 'static + Default + ResourceMarker + Send + Sync>(&self) -> Res {
let Ok(mut guard) = self.resources.lock() else {
return Res::res_default();
};
@@ -103,10 +100,7 @@ where
///
/// Stores a modified resource value back into the global store.
#[doc(hidden)]
- pub fn __store_res<Res: 'static + Send + Sync + ResourceMarker>(
- &self,
- val: Res,
- ) {
+ pub fn __store_res<Res: 'static + Send + Sync + ResourceMarker>(&self, val: Res) {
if let Ok(mut guard) = self.resources.lock() {
guard.insert(TypeId::of::<Res>(), Box::new(Arc::new(val)));
}
diff --git a/mingling_core/src/asset/help.rs b/mingling_core/src/asset/help.rs
index ff2b3d4..b3742f2 100644
--- a/mingling_core/src/asset/help.rs
+++ b/mingling_core/src/asset/help.rs
@@ -6,5 +6,5 @@ pub trait HelpRequest {
type Entry;
/// Process the previous value and write the result into the provided [`RenderResult`](./struct.RenderResult.html)
- fn render_help(p: Self::Entry, r: &mut RenderResult);
+ fn render_help(p: Self::Entry) -> RenderResult;
}
diff --git a/mingling_core/src/asset/renderer.rs b/mingling_core/src/asset/renderer.rs
index 1d5a2c1..732f9b7 100644
--- a/mingling_core/src/asset/renderer.rs
+++ b/mingling_core/src/asset/renderer.rs
@@ -6,5 +6,5 @@ pub trait Renderer {
type Previous;
/// Process the previous value and write the result into the provided [`RenderResult`](./struct.RenderResult.html)
- fn render(p: Self::Previous, r: &mut RenderResult);
+ fn render(p: Self::Previous) -> RenderResult;
}
diff --git a/mingling_core/src/asset/routable.rs b/mingling_core/src/asset/routable.rs
new file mode 100644
index 0000000..24b7bb1
--- /dev/null
+++ b/mingling_core/src/asset/routable.rs
@@ -0,0 +1,22 @@
+use crate::ChainProcess;
+
+/// Provides routing capabilities for converting an item into a `ChainProcess`
+/// directed to either the chain or render processing pipeline.
+///
+/// This trait enables items to be dispatched to different processing routes
+/// (chain or render) by wrapping them into an `AnyOutput` and routing them
+/// through the appropriate pipeline.
+pub trait Routable<Group>
+where
+ Self: Sized + 'static,
+{
+ /// Converts the routable item into a `ChainProcess` directed to the chain route.
+ ///
+ /// This wraps the item into an `AnyOutput` and routes it to the chain processing pipeline.
+ fn to_chain(self) -> ChainProcess<Group>;
+
+ /// Converts the routable item into a `ChainProcess` directed to the render route.
+ ///
+ /// This wraps the item into an `AnyOutput` and routes it to the render processing pipeline.
+ fn to_render(self) -> ChainProcess<Group>;
+}