#[derive(TaskGetters)]Expand description
Derives try_get_*_task functions for enum variants containing task types.
This macro automatically generates getter functions for each variant in a TaskType enum,
eliminating the need for repetitive boilerplate code. These functions retrieve tasks based on
their index (encoded in the Label’s first field) and return the appropriate task type.
§Examples
#[derive(TaskGetters)]
pub enum TaskType<C: Curve> {
ScalarShareTask(Arc<dyn Task<Output = Arc<ScalarShare<C>>>>),
BaseFieldShareTask(Arc<dyn Task<Output = Arc<BaseFieldShare<C>>>>),
// ... more variants
}This generates functions like:
try_get_scalar_share_tasktry_get_base_field_share_tasktry_get_point_share_task
Each function has the signature:
pub fn try_get_<variant_name>_task<C: Curve>(
label: Label,
task_map: &[TaskType<C>],
) -> Result<Arc<dyn Task<Output = Arc<T>>>, ProtocolError>§Requirements
- The enum must have variants with the pattern
*Task(Arc<dyn Task<Output = Arc<T>>>) - The macro extracts the inner type
TfromArc<dyn Task<Output = Arc<T>>> - Each variant must have a corresponding
try_as_*method (typically generated byEnumTryAsInner)