diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-06-26 06:08:12 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-06-26 06:08:12 +0800 |
| commit | e735671acb3a81e1b7e334e56b9ef3963ba0c2fc (patch) | |
| tree | 46562d6630bb1582b41b6741a7a4f482febf84da /mingling_core/src/any | |
| parent | 473cd8e575d03d8bd5439e81cb6835f56a1e964f (diff) | |
feat(core): decouple structured output from Groupped trait
Introduce `StructuralData` sealed trait and `pack_structural!` /
`group_structural!` / `derive(StructuralData)` macros to control
structured rendering separately from grouping. `Groupped` no longer
requires `Serialize`.
Diffstat (limited to 'mingling_core/src/any')
| -rw-r--r-- | mingling_core/src/any/group.rs | 92 |
1 files changed, 26 insertions, 66 deletions
diff --git a/mingling_core/src/any/group.rs b/mingling_core/src/any/group.rs index e9fce5e..07f8400 100644 --- a/mingling_core/src/any/group.rs +++ b/mingling_core/src/any/group.rs @@ -1,74 +1,34 @@ -#[cfg(feature = "general_renderer")] -pub use general_renderer_groupped::*; - -#[cfg(not(feature = "general_renderer"))] -pub use groupped::*; - -#[cfg(feature = "general_renderer")] -mod general_renderer_groupped { - use serde::Serialize; - - use crate::{AnyOutput, ChainProcess}; - /// Used to mark a type with a unique enum ID, assisting dynamic dispatch - pub trait Groupped<Group> +use crate::{AnyOutput, ChainProcess}; + +/// Used to mark a type with a unique enum ID, assisting dynamic dispatch +/// +/// **Note:** Unlike earlier versions, `Groupped` no longer requires `Serialize` +/// even when the `general_renderer` feature is enabled. Structured output is +/// controlled separately via the [`StructalData`] trait. +pub trait Groupped<Group> +where + Self: Sized + 'static, +{ + /// Returns the specific enum value representing its ID within that enum + fn member_id() -> Group; + + /// Converts the grouped 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> where - Self: Sized + Serialize + 'static, + Self: Send, { - /// Returns the specific enum value representing its ID within that enum - fn member_id() -> Group; - - /// Converts the grouped 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> - where - Self: Send + Serialize, - { - AnyOutput::new(self).route_chain() - } - - /// Converts the grouped 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> - where - Self: Send + Serialize, - { - AnyOutput::new(self).route_renderer() - } + AnyOutput::new(self).route_chain() } -} - -#[cfg(not(feature = "general_renderer"))] -mod groupped { - use crate::{AnyOutput, ChainProcess}; - /// Used to mark a type with a unique enum ID, assisting dynamic dispatch - pub trait Groupped<Group> + /// Converts the grouped 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> where - Self: Sized + 'static, + Self: Send, { - /// Returns the specific enum value representing its ID within that enum - fn member_id() -> Group; - - /// Converts the grouped 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> - where - Self: Send, - { - AnyOutput::new(self).route_chain() - } - - /// Converts the grouped 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> - where - Self: Send, - { - AnyOutput::new(self).route_renderer() - } + AnyOutput::new(self).route_renderer() } } |
