1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use crate::{
    serde::{Datum, OptDatum},
    types::Serializable,
};
use derive_more::{Deref, From};
use std::borrow::Borrow;
use std::sync::Arc;

#[derive(From, Deref, PartialEq, Eq, Debug)]
pub struct Value(pub Datum);

pub type PVShared = Arc<Value>;

/* PVShared and OptDatum<PVShared> are Serializable. */
impl Borrow<Datum> for PVShared {
    fn borrow(&self) -> &Datum {
        self
    }
}
impl From<Datum> for PVShared {
    fn from(dat: Datum) -> Self {
        Arc::new(Value(dat))
    }
}
impl Serializable for OptDatum<PVShared> {}