pub unsafe trait NonLocalValue { }Expand description
Marker trait indicating that a type does not contain any instances of Vc or references to
Vc. It may contain ResolvedVc or OperationVc.
This is referred to as “non-local”, as a base Vc type may contain task-local references that
are not valid after the constructing task finishes execution.
Vc can be thought of as containing a lifetime (Vc<'task, T>), and a NonLocalValue can
be thought of as 'static or “owned”. We don’t currently use literal lifetimes for
verbosity reasons, but safety is guaranteed through a combination of this trait and runtime
assertions.
A future version of this trait may be implemented using a combination of auto_traits and
negative_impls, but a derive macro is provided that avoids the need
for these nightly-only features.
§Safety
This trait is marked as unsafe. You should not implement it yourself, but instead you should
rely on #[turbo_tasks::value] or
#[derive(NonLocalValue)] to do it for you.
There may be a few rare cases (e.g. custom generic bounds) where you cannot use
#[turbo_tasks::value]. In these cases, it is your responsibility to ensure that no fields can
contain a Vc or a transitive reference to a Vc.
There are currently runtime assertions in place as a fallback to ensure memory safety, but those assertions may become debug-only in the future if it significantly improves performance.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
impl NonLocalValue for ()
impl NonLocalValue for AtomicBool
impl NonLocalValue for AtomicI8
impl NonLocalValue for AtomicI16
impl NonLocalValue for AtomicI32
impl NonLocalValue for AtomicI64
impl NonLocalValue for AtomicU8
impl NonLocalValue for AtomicU16
impl NonLocalValue for AtomicU32
impl NonLocalValue for AtomicU64
impl NonLocalValue for AtomicUsize
impl NonLocalValue for Duration
impl NonLocalValue for Map<String, Value>
impl NonLocalValue for Path
impl NonLocalValue for PathBuf
impl NonLocalValue for RcStr
impl NonLocalValue for String
impl NonLocalValue for Value
impl NonLocalValue for bool
impl NonLocalValue for char
impl NonLocalValue for f32
impl NonLocalValue for f64
impl NonLocalValue for i8
impl NonLocalValue for i16
impl NonLocalValue for i32
impl NonLocalValue for i64
impl NonLocalValue for i128
impl NonLocalValue for isize
impl NonLocalValue for str
impl NonLocalValue for u8
impl NonLocalValue for u16
impl NonLocalValue for u32
impl NonLocalValue for u64
impl NonLocalValue for u128
impl NonLocalValue for usize
impl<A, Z, Y, X, W, V, U, T, Return> NonLocalValue for fn(A, Z, Y, X, W, V, U, T) -> Return
impl<A: NonLocalValue, Z: NonLocalValue, Y: NonLocalValue, X: NonLocalValue, W: NonLocalValue, V: NonLocalValue, U: NonLocalValue, T: NonLocalValue> NonLocalValue for (A, Z, Y, X, W, V, U, T)
impl<B, A, Z, Y, X, W, V, U, T, Return> NonLocalValue for fn(B, A, Z, Y, X, W, V, U, T) -> Return
impl<B: NonLocalValue + ToOwned + ?Sized> NonLocalValue for Cow<'_, B>
impl<B: NonLocalValue, A: NonLocalValue, Z: NonLocalValue, Y: NonLocalValue, X: NonLocalValue, W: NonLocalValue, V: NonLocalValue, U: NonLocalValue, T: NonLocalValue> NonLocalValue for (B, A, Z, Y, X, W, V, U, T)
impl<C, B, A, Z, Y, X, W, V, U, T, Return> NonLocalValue for fn(C, B, A, Z, Y, X, W, V, U, T) -> Return
impl<C: NonLocalValue, B: NonLocalValue, A: NonLocalValue, Z: NonLocalValue, Y: NonLocalValue, X: NonLocalValue, W: NonLocalValue, V: NonLocalValue, U: NonLocalValue, T: NonLocalValue> NonLocalValue for (C, B, A, Z, Y, X, W, V, U, T)
impl<D, C, B, A, Z, Y, X, W, V, U, T, Return> NonLocalValue for fn(D, C, B, A, Z, Y, X, W, V, U, T) -> Return
impl<D: NonLocalValue, C: NonLocalValue, B: NonLocalValue, A: NonLocalValue, Z: NonLocalValue, Y: NonLocalValue, X: NonLocalValue, W: NonLocalValue, V: NonLocalValue, U: NonLocalValue, T: NonLocalValue> NonLocalValue for (D, C, B, A, Z, Y, X, W, V, U, T)
impl<E, D, C, B, A, Z, Y, X, W, V, U, T, Return> NonLocalValue for fn(E, D, C, B, A, Z, Y, X, W, V, U, T) -> Return
impl<E: NonLocalValue, D: NonLocalValue, C: NonLocalValue, B: NonLocalValue, A: NonLocalValue, Z: NonLocalValue, Y: NonLocalValue, X: NonLocalValue, W: NonLocalValue, V: NonLocalValue, U: NonLocalValue, T: NonLocalValue> NonLocalValue for (E, D, C, B, A, Z, Y, X, W, V, U, T)
impl<K: NonLocalValue, V: NonLocalValue, S, const I: usize> NonLocalValue for AutoMap<K, V, S, I>
impl<K: NonLocalValue, V: NonLocalValue, S> NonLocalValue for HashMap<K, V, S>
impl<K: NonLocalValue, V: NonLocalValue, S> NonLocalValue for IndexMap<K, V, S>
impl<K: NonLocalValue, V: NonLocalValue> NonLocalValue for BTreeMap<K, V>
impl<K: NonLocalValue, V: NonLocalValue> NonLocalValue for FrozenMap<K, V>
impl<L: NonLocalValue, R: NonLocalValue> NonLocalValue for Either<L, R>
impl<T, Return> NonLocalValue for fn(T) -> Return
impl<T: ?Sized> NonLocalValue for PhantomData<T>
impl<T: NonLocalValue + ?Sized> NonLocalValue for &T
impl<T: NonLocalValue + ?Sized> NonLocalValue for &mut T
impl<T: NonLocalValue + ?Sized> NonLocalValue for Arc<T>
impl<T: NonLocalValue + ?Sized> NonLocalValue for Box<T>
impl<T: NonLocalValue + ?Sized> NonLocalValue for Mutex<T>
impl<T: NonLocalValue + ?Sized> NonLocalValue for Mutex<T>
impl<T: NonLocalValue + ?Sized> NonLocalValue for RefCell<T>
impl<T: NonLocalValue, E: NonLocalValue> NonLocalValue for Result<T, E>
impl<T: NonLocalValue, S, const I: usize> NonLocalValue for AutoSet<T, S, I>
impl<T: NonLocalValue, S> NonLocalValue for HashSet<T, S>
impl<T: NonLocalValue, S> NonLocalValue for IndexSet<T, S>
impl<T: NonLocalValue, const N: usize> NonLocalValue for SmallVec<[T; N]>
impl<T: NonLocalValue, const N: usize> NonLocalValue for [T; N]
impl<T: NonLocalValue> NonLocalValue for (T,)
impl<T: NonLocalValue> NonLocalValue for BTreeSet<T>
impl<T: NonLocalValue> NonLocalValue for FrozenSet<T>
impl<T: NonLocalValue> NonLocalValue for Option<T>
impl<T: NonLocalValue> NonLocalValue for Vec<T>
impl<T: NonLocalValue> NonLocalValue for [T]
impl<T> NonLocalValue for Pin<T>
impl<U, T, Return> NonLocalValue for fn(U, T) -> Return
impl<U: NonLocalValue, T: NonLocalValue> NonLocalValue for (U, T)
impl<V, U, T, Return> NonLocalValue for fn(V, U, T) -> Return
impl<V: NonLocalValue, U: NonLocalValue, T: NonLocalValue> NonLocalValue for (V, U, T)
impl<W, V, U, T, Return> NonLocalValue for fn(W, V, U, T) -> Return
impl<W: NonLocalValue, V: NonLocalValue, U: NonLocalValue, T: NonLocalValue> NonLocalValue for (W, V, U, T)
impl<X, W, V, U, T, Return> NonLocalValue for fn(X, W, V, U, T) -> Return
impl<X: NonLocalValue, W: NonLocalValue, V: NonLocalValue, U: NonLocalValue, T: NonLocalValue> NonLocalValue for (X, W, V, U, T)
impl<Y, X, W, V, U, T, Return> NonLocalValue for fn(Y, X, W, V, U, T) -> Return
impl<Y: NonLocalValue, X: NonLocalValue, W: NonLocalValue, V: NonLocalValue, U: NonLocalValue, T: NonLocalValue> NonLocalValue for (Y, X, W, V, U, T)
impl<Z, Y, X, W, V, U, T, Return> NonLocalValue for fn(Z, Y, X, W, V, U, T) -> Return
impl<Z: NonLocalValue, Y: NonLocalValue, X: NonLocalValue, W: NonLocalValue, V: NonLocalValue, U: NonLocalValue, T: NonLocalValue> NonLocalValue for (Z, Y, X, W, V, U, T)
Implementors§
impl NonLocalValue for Completion
impl NonLocalValue for Completions
impl NonLocalValue for Effects
impl NonLocalValue for Error
impl NonLocalValue for Event
impl NonLocalValue for Invalidator
impl NonLocalValue for SerializationInvalidator
impl NonLocalValue for TaskId
impl<T, E> NonLocalValue for AdjacencyMap<T, E>where
T: NonLocalValue,
E: NonLocalValue,
impl<T: NonLocalValue + ?Sized> NonLocalValue for GcRoot<T>
Safety: mirrors the OperationVc impl — a GcRoot holds no task-local data beyond the
operation it pins.