Skip to main content

RawVc

Struct RawVc 

Source
pub struct RawVc(/* private fields */);
Expand description

A type-erased representation of Vc.

Type erasure reduces the monomorphization (and therefore binary size and compilation time) required to support Vc.

This type is heavily used within the Backend trait, but should otherwise be treated as an internal implementation detail of turbo-tasks.

§Representation

RawVc is one of three logical variants (see RawVcUnpacked) bit-packed into a single NonZeroU64.

Bit 31 is the discriminator between a local output and a task variant; the two task variants are then told apart by whether the CellId field (the high 32 bits) is zero — which is unambiguous because every CellId is non-zero.

bit31 = 1                  LocalOutput: 1<<31 | transient(1) | ExecutionId(16) << 1 | LocalTaskId(32) << 32
bit31 = 0, bits32..63 == 0 TaskOutput:  TaskId(31)
bit31 = 0, bits32..63 != 0 TaskCell:    TaskId(31) | CellId(32) << 32

Implementations§

Source§

impl RawVc

Source

pub fn task_output(task: TaskId) -> Self

Packs the synchronous return value of a task. The word is simply the TaskId value: bit 31 clear (a task variant) and the cell field zero (no cell).

Source

pub fn task_cell(task: TaskId, cell: CellId) -> Self

Packs a pointer to a specific cell within a task: the TaskId in the low bits and the non-zero CellId in the high 32 bits.

Source

pub fn local_output( execution_id: ExecutionId, local_task_id: LocalTaskId, persistence: TaskPersistence, ) -> Self

Packs the synchronous return value of a local task, marked by bit 31.

Source

pub fn unpack(self) -> RawVcUnpacked

Unpacks into the logical RawVcUnpacked enum for matching.

Source

pub fn as_task_output(self) -> Option<TaskId>

Returns the TaskId if this is a TaskOutput, otherwise None.

Prefer this over unpack when a caller only cares about the TaskOutput case: it reads just the discriminator and the task bits.

Source

pub fn as_task_cell(self) -> Option<(TaskId, CellId)>

Returns the (TaskId, CellId) pair if this is a TaskCell, otherwise None.

Prefer this over unpack when a caller only cares about the TaskCell case: it reads just the discriminator, the task bits, and the cell bits.

Source

pub fn as_local_output( self, ) -> Option<(ExecutionId, LocalTaskId, TaskPersistence)>

Returns the (ExecutionId, LocalTaskId, TaskPersistence) triple if this is a LocalOutput, otherwise None.

Prefer this over unpack when a caller only cares about the LocalOutput case.

Source§

impl RawVc

Source

pub fn is_resolved(&self) -> bool

Source

pub fn is_local_output(&self) -> bool

Source

pub fn is_transient(&self) -> bool

Returns true if the task this RawVc reads from cannot be serialized and will not be stored in the filesystem cache.

See TaskPersistence for more details.

Source

pub async fn to_non_local(self) -> Result<RawVc>

Convert a potentially local RawVc into a non-local RawVc. This is a subset of resolution resolution, because the returned RawVc can be a TaskOutput.

Source

pub fn try_get_task_id(&self) -> Option<TaskId>

Source

pub fn try_get_type_id(&self) -> Option<ValueTypeId>

Trait Implementations§

Source§

impl<'__de, __Context> BorrowDecode<'__de, __Context> for RawVc

Source§

fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>( decoder: &mut __D, ) -> Result<Self, DecodeError>

Attempt to decode this type with the given BorrowDecode.
Source§

impl Clone for RawVc

Source§

fn clone(&self) -> RawVc

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl CollectiblesSource for RawVc

This implementation of CollectiblesSource assumes that self is a RawVc::TaskOutput.

Source§

impl Debug for RawVc

Source§

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

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

impl<__Context> Decode<__Context> for RawVc

Source§

fn decode<__D: Decoder<Context = __Context>>( decoder: &mut __D, ) -> Result<Self, DecodeError>

Attempt to decode this type with the given Decode.
Source§

impl<'de> Deserialize<'de> for RawVc

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 Display for RawVc

Source§

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

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

impl Encode for RawVc

Source§

fn encode<__E: Encoder>(&self, encoder: &mut __E) -> Result<(), EncodeError>

Encode a given type.
Source§

impl From<CurrentCellRef> for RawVc

Source§

fn from(cell: CurrentCellRef) -> Self

Converts to this type from the input type.
Source§

impl<T> From<RawVc> for Vc<T>
where T: ?Sized,

Source§

fn from(node: RawVc) -> Self

Converts to this type from the input type.
Source§

impl Hash for RawVc

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 PartialEq for RawVc

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 Serialize for RawVc

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 TraceRawVcs for RawVc

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> 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 Copy for RawVc

Source§

impl Eq for RawVc

Source§

impl StructuralPartialEq for RawVc

Auto Trait Implementations§

§

impl Freeze for RawVc

§

impl RefUnwindSafe for RawVc

§

impl Send for RawVc

§

impl Sync for RawVc

§

impl Unpin for RawVc

§

impl UnsafeUnpin for RawVc

§

impl UnwindSafe for RawVc

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

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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
§

impl<T> DynHash for T
where T: Any + Hash,

§

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

§

impl<T> DynPartialEq for T
where T: Any + PartialEq,

§

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

Source§

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

Source§

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

§

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

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

impl<T> LayoutRaw for T

§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
§

impl<T> Pointee for T

§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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<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>,

§

impl<T> DynEq for T
where T: Any + Eq,