Skip to main content

Call

Struct Call 

Source
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>

Source

pub fn new(task: &'a T, params: T::Params) -> Self

Create a new call with the given task and parameters.

Source

pub fn task(&self) -> &T

Get a reference to the task.

Source

pub fn params(&self) -> &T::Params

Get a reference to the parameters.

Source

pub fn into_params(self) -> T::Params

Consume the call and return the parameters.

Source

pub fn serialize_params(&self) -> RustvelloResult<String>

Serialize the parameters to a JSON string.

Source

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.

Source

pub fn call_id(&self) -> RustvelloResult<CallId>

Compute the deterministic CallId for this call.

Source

pub fn to_dto(&self) -> RustvelloResult<CallDTO>

Convert to a CallDTO suitable for persistence.

Source

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:

  • UnlimitedNone (no concurrency check needed)
  • TaskSome(empty) (task-level only, no args)
  • ArgumentSome(all args) or Some(key_arguments subset) if key_arguments is set
  • NoneSome(all args) (strictest: full dedup)

Auto Trait Implementations§

§

impl<'a, T> Freeze for Call<'a, T>
where <T as Task>::Params: Freeze,

§

impl<'a, T> RefUnwindSafe for Call<'a, T>

§

impl<'a, T> Send for Call<'a, T>

§

impl<'a, T> Sync for Call<'a, T>

§

impl<'a, T> Unpin for Call<'a, T>
where <T as Task>::Params: Unpin, <T as Task>::Result: Unpin,

§

impl<'a, T> UnsafeUnpin for Call<'a, T>
where <T as Task>::Params: UnsafeUnpin,

§

impl<'a, T> UnwindSafe for Call<'a, T>
where <T as Task>::Params: UnwindSafe, T: RefUnwindSafe, <T as Task>::Result: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more