Trait VcRead

Source
pub trait VcRead<T>
where T: VcValueType,
{ type Target; type Repr: VcValueType; // Required methods fn value_to_target_ref(value: &T) -> &Self::Target; fn value_to_target(value: T) -> Self::Target; fn value_to_repr(value: T) -> Self::Repr; fn target_to_value(target: Self::Target) -> T; fn target_to_value_ref(target: &Self::Target) -> &T; fn target_to_value_mut_ref(target: &mut Self::Target) -> &mut T; fn target_to_repr(target: Self::Target) -> Self::Repr; fn repr_to_value_ref(repr: &Self::Repr) -> &T; }
Expand description

Trait that controls crate::Vc’s read representation.

Has two implementations:

This trait must remain sealed within this crate.

Required Associated Types§

Source

type Target

The read target type. This is the type that will be returned when .awaiting a Vc of a value type.

For instance, the target of .awaiting a Vc<Completion> will be a Completion. When using #[turbo_tasks::value(transparent)], the target will be different than the value type.

Source

type Repr: VcValueType

The representation type. This is what will be used to serialize/deserialize the value, and this determines the type that the value will be upcasted to for storage.

For instance, when storing generic collection types such as Vec<Vc<ValueType>>, we first cast them to a shared Vec<Vc<()>> type instead, which has an equivalent memory representation to any Vec<Vc<T>> type. This allows sharing implementations of methods and traits between all Vec<Vc<T>>.

Required Methods§

Source

fn value_to_target_ref(value: &T) -> &Self::Target

Convert a reference to a value to a reference to the target type.

Source

fn value_to_target(value: T) -> Self::Target

Convert a value to the target type.

Source

fn value_to_repr(value: T) -> Self::Repr

Convert the value type to the repr.

Source

fn target_to_value(target: Self::Target) -> T

Convert the target type to the value.

Source

fn target_to_value_ref(target: &Self::Target) -> &T

Convert a reference to a target type to a reference to a value.

Source

fn target_to_value_mut_ref(target: &mut Self::Target) -> &mut T

Convert a mutable reference to a target type to a reference to a value.

Source

fn target_to_repr(target: Self::Target) -> Self::Repr

Convert the target type to the repr.

Source

fn repr_to_value_ref(repr: &Self::Repr) -> &T

Convert a reference to a repr type to a reference to a value.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T> VcRead<T> for VcDefaultRead<T>
where T: VcValueType,

Source§

type Target = T

Source§

type Repr = T

Source§

impl<T, Target, Repr> VcRead<T> for VcTransparentRead<T, Target, Repr>
where T: VcValueType, Target: Any + Send + Sync, Repr: VcValueType,

Source§

type Target = Target

Source§

type Repr = Repr