Struct ResolvedVc

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

A “subtype” (via Deref) of Vc that represents a specific Vc::cell/.cell() or ResolvedVc::cell/.resolved_cell() constructor call within a task.

Unlike Vc, ResolvedVc:

  • 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.

  • Points to a concrete value with a type, and is therefore cheap to downcast.

§Construction

There are a few ways to construct a ResolvedVc, in order of preference:

  1. Given a value, construct a ResolvedVc using ResolvedVc::cell (for “transparent” values) or by calling the generated .resolved_cell() constructor on the value type.

  2. Given an argument to a function using the #[turbo_tasks::function] macro, change the argument’s type to a ResolvedVc. The rewritten external signature will still use Vc, but when the function is called, the Vc will be resolved.

  3. Given a Vc, use .to_resolved().await?.

§Equality & Hashing

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

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

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

Implementations§

Source§

impl<T> ResolvedVc<T>
where T: ?Sized,

Source

pub async fn to_resolved(self) -> Result<Self>

👎Deprecated: No point in resolving a vc that is already resolved

This function exists to intercept calls to Vc::to_resolved through dereferencing a ResolvedVc. Converting to Vc and re-resolving it puts unnecessary stress on the turbo tasks engine.

Source

pub async fn resolve(self) -> Result<Vc<T>>

👎Deprecated: No point in resolving a vc that is already resolved
Source§

impl<T, Inner, Repr> ResolvedVc<T>
where T: VcValueType<Read = VcTransparentRead<T, Inner, Repr>>, Inner: Any + Send + Sync, Repr: VcValueType,

Source

pub fn cell(inner: Inner) -> Self

Source§

impl<T> ResolvedVc<T>
where T: ?Sized,

Source

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

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

See also: Vc::upcast.

Source

pub fn deref_vec(vec: Vec<ResolvedVc<T>>) -> Vec<Vc<T>>

Cheaply converts a Vec of resolved Vcs to a Vec of Vcs.

Source

pub fn deref_slice(slice: &[ResolvedVc<T>]) -> &[Vc<T>]

Cheaply converts a slice of resolved Vcs to a slice of Vcs.

Source§

impl<T> ResolvedVc<T>
where T: VcValueTrait + ?Sized,

Source

pub fn try_sidecast<K>(this: Self) -> Option<ResolvedVc<K>>
where K: VcValueTrait + ?Sized,

Returns None if the underlying value type does not implement K.

Note: if the trait T is required to implement K, use ResolvedVc::upcast instead. This provides stronger guarantees, removing the need for a Result return type.

See also: Vc::try_resolve_sidecast.

Source

pub fn try_downcast<K>(this: Self) -> Option<ResolvedVc<K>>
where K: Upcast<T> + VcValueTrait + ?Sized,

Attempts to downcast the given ResolvedVc<Box<dyn T>> to a ResolvedVc<K>, where K is of the form Box<dyn L>, and L is a value trait.

Returns None if the underlying value type is not a K.

See also: Vc::try_resolve_downcast.

Source

pub fn try_downcast_type<K>(this: Self) -> Option<ResolvedVc<K>>
where K: Upcast<T> + VcValueType,

Attempts to downcast the given Vc<Box<dyn T>> to a Vc<K>, where K is a value type.

Returns None if the underlying value type is not a K.

See also: Vc::try_resolve_downcast_type.

Trait Implementations§

Source§

impl<T> Clone for ResolvedVc<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> Debug for ResolvedVc<T>
where T: ?Sized,

Generates an opaque debug representation of the ResolvedVc itself, but not the data inside of it.

This is implemented to allow types containing ResolvedVc to implement the synchronous Debug trait, but in most cases users should use the ValueDebug implementation to get a string representation of the contents of the cell.

Source§

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

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

impl<T, Inner, Repr> Default for ResolvedVc<T>
where T: VcValueType<Read = VcTransparentRead<T, Inner, Repr>>, Inner: Any + Send + Sync + Default, Repr: VcValueType,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T> Deref for ResolvedVc<T>
where T: ?Sized,

Source§

type Target = Vc<T>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

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

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

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

impl<T> FromTaskInput for ResolvedVc<T>
where T: Send + Sync + ?Sized,

Source§

impl<T> Hash for ResolvedVc<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> IntoFuture for &ResolvedVc<T>
where T: VcValueType,

Source§

type Output = <Vc<T> as IntoFuture>::Output

The output that the future will produce on completion.
Source§

type IntoFuture = <Vc<T> as IntoFuture>::IntoFuture

Which kind of future are we turning this into?
Source§

fn into_future(self) -> Self::IntoFuture

Creates a future from a value. Read more
Source§

impl<T> IntoFuture for &mut ResolvedVc<T>
where T: VcValueType,

Source§

type Output = <Vc<T> as IntoFuture>::Output

The output that the future will produce on completion.
Source§

type IntoFuture = <Vc<T> as IntoFuture>::IntoFuture

Which kind of future are we turning this into?
Source§

fn into_future(self) -> Self::IntoFuture

Creates a future from a value. Read more
Source§

impl<T> IntoFuture for ResolvedVc<T>
where T: VcValueType,

Source§

type Output = <Vc<T> as IntoFuture>::Output

The output that the future will produce on completion.
Source§

type IntoFuture = <Vc<T> as IntoFuture>::IntoFuture

Which kind of future are we turning this into?
Source§

fn into_future(self) -> Self::IntoFuture

Creates a future from a value. Read more
Source§

impl<T> PartialEq for ResolvedVc<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 ResolvedVc<T>
where T: ?Sized,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

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

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

Source§

fn is_resolved(&self) -> bool

Source§

fn is_transient(&self) -> bool

Source§

async fn resolve_input(&self) -> Result<Self>

Source§

impl<T> TraceRawVcs for ResolvedVc<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 ResolvedVc<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> ValueDebugFormat for ResolvedVc<T>
where T: Upcast<Box<dyn ValueDebug>> + Send + Sync + ?Sized,

Source§

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

Source§

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

Source§

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

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<T> UnwindSafe for ResolvedVc<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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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>,