pub struct Call<'a, T: Task> { /* private fields */ }Expand description
A typed task call with concrete parameters.
Mirrors pynenc’s Call class. Holds a reference to the task and the
typed parameters. Lazily serializes the parameters and computes the
deterministic CallId on demand.
§Example
use rustvello_core::call::Call;
use rustvello_core::task::Task;
use rustvello_proto::config::TaskConfig;
use rustvello_proto::identifiers::TaskId;
use rustvello_core::error::RustvelloResult;
struct DoubleTask { task_id: TaskId, config: TaskConfig }
impl DoubleTask {
fn new() -> Self {
Self { task_id: TaskId::new("example", "double"), config: TaskConfig::default() }
}
}
impl Task for DoubleTask {
type Params = i32;
type Result = i32;
fn task_id(&self) -> &TaskId { &self.task_id }
fn config(&self) -> &TaskConfig { &self.config }
fn run(&self, x: i32) -> RustvelloResult<i32> { Ok(x * 2) }
}
let task = DoubleTask::new();
let call = Call::new(&task, 21);
let dto = call.to_dto().unwrap();
assert_eq!(dto.task_id, TaskId::new("example", "double"));Implementations§
Source§impl<'a, T: Task> Call<'a, T>
impl<'a, T: Task> Call<'a, T>
Sourcepub fn new(task: &'a T, params: T::Params) -> Self
pub fn new(task: &'a T, params: T::Params) -> Self
Create a new call with the given task and parameters.
Sourcepub fn into_params(self) -> T::Params
pub fn into_params(self) -> T::Params
Consume the call and return the parameters.
Sourcepub fn serialize_params(&self) -> RustvelloResult<String>
pub fn serialize_params(&self) -> RustvelloResult<String>
Serialize the parameters to a JSON string.
Sourcepub fn serialized_arguments(&self) -> RustvelloResult<SerializedArguments>
pub fn serialized_arguments(&self) -> RustvelloResult<SerializedArguments>
Compute the serialized arguments as a SerializedArguments.
For struct-like params, each field becomes a key-value pair.
For other types (primitives, tuples), the entire value is stored
under a single "__args__" key.
Sourcepub fn call_id(&self) -> RustvelloResult<CallId>
pub fn call_id(&self) -> RustvelloResult<CallId>
Compute the deterministic CallId for this call.
Sourcepub fn to_dto(&self) -> RustvelloResult<CallDTO>
pub fn to_dto(&self) -> RustvelloResult<CallDTO>
Convert to a CallDTO suitable for persistence.
Sourcepub fn serialized_args_for_concurrency_check(
&self,
) -> RustvelloResult<Option<SerializedArguments>>
pub fn serialized_args_for_concurrency_check( &self, ) -> RustvelloResult<Option<SerializedArguments>>
Returns the serialized arguments relevant for concurrency checking.
Mirrors pynenc’s Call.serialized_args_for_concurrency_check.
The result depends on the task’s concurrency control configuration:
Unlimited→None(no concurrency check needed)Task→Some(empty)(task-level only, no args)Argument→Some(all args)orSome(key_arguments subset)if key_arguments is setNone→Some(all args)(strictest: full dedup)