Struct OperationVc

Source
pub struct OperationVc<T>
where T: ?Sized,
{ /* private fields */ }
Expand description

A “subtype” (can be converted via .connect()) of Vc that represents a specific call (with arguments) to a task.

Unlike Vc, OperationVc:

  • Does not potentially refer to task-local information, meaning that it implements NonLocalValue, and can be used in any #[turbo_tasks::value].

  • Has only one potential internal representation, meaning that it has a saner equality definition.

  • Can be reconnected to the strongly-consistent compilation graph after being placed inside of a State.

  • Makes sense with collectibles, as it represents a function call, and only function calls can have issues or side-effects.

§Equality & Hashing

Equality between two OperationVcs means that both have an identical in-memory representation and point to the same task function call. The implementation of Hash has similar behavior.

If connected and then .awaited at the same time, both would likely resolve to the same ReadRef, though it is possible that they may not if the task or cell is invalidated between .awaits.

Because equality is a synchronous operation that cannot read the cell contents, even if the OperationVcs are not equal, it is possible that if .awaited, both OperationVcs could point to the same or equal values.

Implementations§

Source§

impl<T: ?Sized> OperationVc<T>

Source

pub fn connect(self) -> Vc<T>

Marks this operation’s underlying function call as a child of the current task, and returns a Vc that can be resolved or read with .await?.

By marking this function call as a child of the current task, turbo-tasks will re-run tasks as-needed to achieve strong consistency at the root of the function call tree. This explicit operation is needed as OperationVc types can be stored outside of the call graph as part of States.

Source

pub fn into_raw(vc: Self) -> RawVc

Returns the RawVc corresponding to this Vc.

Source

pub fn upcast<K>(vc: Self) -> OperationVc<K>
where T: Upcast<K>, K: VcValueTrait + ?Sized,

Upcasts the given OperationVc<T> to a OperationVc<Box<dyn K>>.

This is also available as an Into/From conversion.

Source

pub async fn resolve_strongly_consistent(self) -> Result<ResolvedVc<T>>

Connects the OperationVc and resolves the reference until it points to a cell directly in a strongly consistent way.

Resolving will wait for task execution to be finished, so that the returned ResolvedVc points to a cell that stores a value.

Resolving is necessary to compare identities of Vcs.

This is async and will rethrow any fatal error that happened during task execution.

Source

pub fn read_strongly_consistent(self) -> ReadVcFuture<T>
where T: VcValueType,

Connects the OperationVc and returns a strongly consistent read of the value.

This ensures that all internal tasks are finished before the read is returned.

Trait Implementations§

Source§

impl<T> Clone for OperationVc<T>
where T: ?Sized,

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> CollectiblesSource for OperationVc<T>
where T: ?Sized,

Source§

impl<T> Debug for OperationVc<T>
where T: ?Sized,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de, T> Deserialize<'de> for OperationVc<T>
where T: ?Sized,

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T> Hash for OperationVc<T>
where T: ?Sized,

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T> PartialEq for OperationVc<T>
where T: ?Sized,

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> Serialize for OperationVc<T>
where T: ?Sized,

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl<T> TaskInput for OperationVc<T>
where T: ?Sized + Send + Sync,

Source§

fn is_transient(&self) -> bool

Source§

fn resolve_input(&self) -> impl Future<Output = Result<Self>> + Send + '_

Source§

fn is_resolved(&self) -> bool

Source§

impl<T> TraceRawVcs for OperationVc<T>
where T: ?Sized,

Source§

fn trace_raw_vcs(&self, trace_context: &mut TraceRawVcsContext)

Source§

fn get_raw_vcs(&self) -> Vec<RawVc>

Source§

impl<T> TryFrom<RawVc> for OperationVc<T>
where T: ?Sized,

Source§

type Error = Error

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

fn try_from(raw: RawVc) -> Result<Self>

Performs the conversion.
Source§

impl<T> Copy for OperationVc<T>
where T: ?Sized,

Source§

impl<T> Eq for OperationVc<T>
where T: ?Sized,

Source§

impl<T: NonLocalValue + ?Sized> NonLocalValue for OperationVc<T>

Source§

impl<T: ?Sized + Send> OperationValue for OperationVc<T>

Auto Trait Implementations§

§

impl<T> Freeze for OperationVc<T>
where T: ?Sized,

§

impl<T> RefUnwindSafe for OperationVc<T>
where T: RefUnwindSafe + ?Sized,

§

impl<T> Send for OperationVc<T>
where T: Send + ?Sized,

§

impl<T> Sync for OperationVc<T>
where T: Sync + ?Sized,

§

impl<T> Unpin for OperationVc<T>
where T: ?Sized,

§

impl<T> UnwindSafe for OperationVc<T>
where T: UnwindSafe + ?Sized,

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
§

impl<T> Any for T
where T: Any,

§

fn get_type_id(&self) -> TypeId

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynamicEqHash for T
where T: Any + PartialEq + Eq + Hash,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

fn dyn_eq(&self, other: &(dyn Any + 'static)) -> bool

Source§

fn dyn_hash(&self, state: &mut dyn Hasher)

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> MagicAny for T
where T: Debug + Eq + Hash + Send + Sync + TraceRawVcs + 'static,

Source§

fn magic_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Source§

fn magic_debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Source§

fn magic_eq(&self, other: &(dyn MagicAny + 'static)) -> bool

Source§

fn magic_hash(&self, hasher: &mut dyn Hasher)

Source§

fn magic_trace_raw_vcs(&self, trace_context: &mut TraceRawVcsContext)

Source§

fn magic_type_name(&self) -> &'static str

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,