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:
-
Given a value, construct a
ResolvedVcusingResolvedVc::cell(for “transparent” values) or by calling the generated.resolved_cell()constructor on the value type. -
Given an argument to a function using the
#[turbo_tasks::function]macro, change the argument’s type to aResolvedVc. The rewritten external signature will still useVc, but when the function is called, theVcwill be resolved. -
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,
impl<T> ResolvedVc<T>where
T: ?Sized,
Sourcepub async fn to_resolved(self) -> Result<Self>
👎Deprecated: No point in resolving a vc that is already resolved
pub async fn to_resolved(self) -> Result<Self>
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.
pub async fn resolve(self) -> Result<Vc<T>>
Source§impl<T, Inner, Repr> ResolvedVc<T>where
T: VcValueType<Read = VcTransparentRead<T, Inner, Repr>>,
Inner: Any + Send + Sync,
Repr: VcValueType,
impl<T, Inner, Repr> ResolvedVc<T>where
T: VcValueType<Read = VcTransparentRead<T, Inner, Repr>>,
Inner: Any + Send + Sync,
Repr: VcValueType,
Source§impl<T> ResolvedVc<T>where
T: ?Sized,
impl<T> ResolvedVc<T>where
T: ?Sized,
Sourcepub fn upcast<K>(this: Self) -> ResolvedVc<K>
pub fn upcast<K>(this: Self) -> ResolvedVc<K>
Upcasts the given ResolvedVc<T> to a ResolvedVc<Box<dyn K>>.
See also: Vc::upcast.
Sourcepub fn upcast_non_strict<K>(this: Self) -> ResolvedVc<K>
pub fn upcast_non_strict<K>(this: Self) -> ResolvedVc<K>
Upcasts the given ResolvedVc<T> to a ResolvedVc<Box<dyn K>>.
This has a loose type constraint which would allow upcasting to the same type, prefer using
ResolvedVc::upcast when possible. See also: Vc::upcast_non_strict. This is
useful for extension traits and other more generic usecases.
Sourcepub fn upcast_vec<K>(vec: Vec<Self>) -> Vec<ResolvedVc<K>>
pub fn upcast_vec<K>(vec: Vec<Self>) -> Vec<ResolvedVc<K>>
Upcasts the given Vec<ResolvedVc<T>> to a Vec<ResolvedVc<K>>.
See also: Vc::upcast.
Sourcepub fn deref_vec(vec: Vec<ResolvedVc<T>>) -> Vec<Vc<T>>
pub fn deref_vec(vec: Vec<ResolvedVc<T>>) -> Vec<Vc<T>>
Cheaply converts a Vec of resolved Vcs to a Vec of Vcs.
Sourcepub fn deref_slice(slice: &[ResolvedVc<T>]) -> &[Vc<T>]
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,
impl<T> ResolvedVc<T>where
T: VcValueTrait + ?Sized,
Sourcepub fn try_sidecast<K>(this: Self) -> Option<ResolvedVc<K>>where
K: VcValueTrait + ?Sized,
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.
That method provides stronger guarantees, removing the need for a Option return type.
See also: Vc::try_resolve_sidecast.
Sourcepub fn try_downcast<K>(this: Self) -> Option<ResolvedVc<K>>
pub fn try_downcast<K>(this: Self) -> Option<ResolvedVc<K>>
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.
Sourcepub fn try_downcast_type<K>(this: Self) -> Option<ResolvedVc<K>>where
K: UpcastStrict<T> + VcValueType,
pub fn try_downcast_type<K>(this: Self) -> Option<ResolvedVc<K>>where
K: UpcastStrict<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,
impl<T> Clone for ResolvedVc<T>where
T: ?Sized,
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.
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§impl<T, Inner, Repr> Default for ResolvedVc<T>where
T: VcValueType<Read = VcTransparentRead<T, Inner, Repr>>,
Inner: Any + Send + Sync + Default,
Repr: VcValueType,
impl<T, Inner, Repr> Default for ResolvedVc<T>where
T: VcValueType<Read = VcTransparentRead<T, Inner, Repr>>,
Inner: Any + Send + Sync + Default,
Repr: VcValueType,
Source§impl<T> Deref for ResolvedVc<T>where
T: ?Sized,
impl<T> Deref for ResolvedVc<T>where
T: ?Sized,
Source§impl<'de, T> Deserialize<'de> for ResolvedVc<T>where
T: ?Sized,
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>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<T> FromTaskInput for ResolvedVc<T>
impl<T> FromTaskInput for ResolvedVc<T>
type TaskInput = Vc<T>
fn from_task_input(from: Vc<T>) -> ResolvedVc<T>
Source§impl<T> Hash for ResolvedVc<T>where
T: ?Sized,
impl<T> Hash for ResolvedVc<T>where
T: ?Sized,
Source§impl<T> IntoFuture for &ResolvedVc<T>where
T: VcValueType,
impl<T> IntoFuture for &ResolvedVc<T>where
T: VcValueType,
Source§type Output = <Vc<T> as IntoFuture>::Output
type Output = <Vc<T> as IntoFuture>::Output
Source§type IntoFuture = <Vc<T> as IntoFuture>::IntoFuture
type IntoFuture = <Vc<T> as IntoFuture>::IntoFuture
Source§fn into_future(self) -> Self::IntoFuture
fn into_future(self) -> Self::IntoFuture
Source§impl<T> IntoFuture for &mut ResolvedVc<T>where
T: VcValueType,
impl<T> IntoFuture for &mut ResolvedVc<T>where
T: VcValueType,
Source§type Output = <Vc<T> as IntoFuture>::Output
type Output = <Vc<T> as IntoFuture>::Output
Source§type IntoFuture = <Vc<T> as IntoFuture>::IntoFuture
type IntoFuture = <Vc<T> as IntoFuture>::IntoFuture
Source§fn into_future(self) -> Self::IntoFuture
fn into_future(self) -> Self::IntoFuture
Source§impl<T> IntoFuture for ResolvedVc<T>where
T: VcValueType,
impl<T> IntoFuture for ResolvedVc<T>where
T: VcValueType,
Source§type Output = <Vc<T> as IntoFuture>::Output
type Output = <Vc<T> as IntoFuture>::Output
Source§type IntoFuture = <Vc<T> as IntoFuture>::IntoFuture
type IntoFuture = <Vc<T> as IntoFuture>::IntoFuture
Source§fn into_future(self) -> Self::IntoFuture
fn into_future(self) -> Self::IntoFuture
Source§impl<T> PartialEq for ResolvedVc<T>where
T: ?Sized,
impl<T> PartialEq for ResolvedVc<T>where
T: ?Sized,
Source§impl<T> Serialize for ResolvedVc<T>where
T: ?Sized,
impl<T> Serialize for ResolvedVc<T>where
T: ?Sized,
Source§impl<T> TaskInput for ResolvedVc<T>
impl<T> TaskInput for ResolvedVc<T>
fn is_resolved(&self) -> bool
fn is_transient(&self) -> bool
async fn resolve_input(&self) -> Result<Self>
Source§impl<T> TraceRawVcs for ResolvedVc<T>where
T: ?Sized,
impl<T> TraceRawVcs for ResolvedVc<T>where
T: ?Sized,
fn trace_raw_vcs(&self, trace_context: &mut TraceRawVcsContext)
fn get_raw_vcs(&self) -> Vec<RawVc>
Source§impl<T> ValueDebugFormat for ResolvedVc<T>
impl<T> ValueDebugFormat for ResolvedVc<T>
fn value_debug_format(&self, depth: usize) -> ValueDebugFormatString<'_>
impl<T> Copy for ResolvedVc<T>where
T: ?Sized,
impl<T> Eq for ResolvedVc<T>where
T: ?Sized,
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>
impl<T> Sync for ResolvedVc<T>
impl<T> Unpin for ResolvedVc<T>where
T: ?Sized,
impl<T> UnwindSafe for ResolvedVc<T>where
T: UnwindSafe + ?Sized,
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> DynPartialEq for T
impl<T> DynPartialEq for T
fn dyn_partial_eq(&self, other: &(dyn Any + 'static)) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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