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§
Sourcetype Target
type Target
The read target type. This is the type that will be returned when
.await
ing a Vc
of a value type.
For instance, the target of .await
ing a Vc<Completion>
will be a
Completion
. When using #[turbo_tasks::value(transparent)]
, the
target will be different than the value type.
Sourcetype Repr: VcValueType
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§
Sourcefn value_to_target_ref(value: &T) -> &Self::Target
fn value_to_target_ref(value: &T) -> &Self::Target
Convert a reference to a value to a reference to the target type.
Sourcefn value_to_target(value: T) -> Self::Target
fn value_to_target(value: T) -> Self::Target
Convert a value to the target type.
Sourcefn value_to_repr(value: T) -> Self::Repr
fn value_to_repr(value: T) -> Self::Repr
Convert the value type to the repr.
Sourcefn target_to_value(target: Self::Target) -> T
fn target_to_value(target: Self::Target) -> T
Convert the target type to the value.
Sourcefn target_to_value_ref(target: &Self::Target) -> &T
fn target_to_value_ref(target: &Self::Target) -> &T
Convert a reference to a target type to a reference to a value.
Sourcefn target_to_value_mut_ref(target: &mut Self::Target) -> &mut T
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.
Sourcefn target_to_repr(target: Self::Target) -> Self::Repr
fn target_to_repr(target: Self::Target) -> Self::Repr
Convert the target type to the repr.
Sourcefn repr_to_value_ref(repr: &Self::Repr) -> &T
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.