1use crate::AsmResult;
2use std::cell::UnsafeCell;
3use std::sync::Arc;
4
5#[derive(Clone, Debug)]
6pub enum InnerValue<V> {
7 UnInit,
8 Initialized(V),
9}
10
11
12#[derive(Debug)]
13pub struct Computable<V> {
14 pub(crate) inner_value: UnsafeCell<InnerValue<Arc<V>>>,
15}
16
17pub trait ComputableOwner<V> {
18 fn computable_ref(&self) -> &Computable<V>;
19 fn compute(&self) -> AsmResult<V>;
20}
21
22
23pub trait ComputableAccessor<V> {
24 fn force(&self) -> AsmResult<Arc<V>>;
25}
26
27pub struct ComputableSizedVec<V> {
28 pub(crate) vec_ref: Vec<Computable<V>>,
29}
30
31pub trait ComputableSizedVecOwner<V> {
32 fn computable_vec(&self) -> &ComputableSizedVec<V>;
33 fn compute(&self, index: usize) -> AsmResult<V>;
34}
35
36pub trait ComputableSizedVecAccessor<V> {
37 fn get_or_compute(&self, index: usize) -> AsmResult<Arc<V>>;
40}