use crate::{change_graph::ChangeGraph, CollaborativeObject, Evaluate, ObjectId, Store, TypeName};
use super::error;
pub fn get<T, S>(
storage: &S,
typename: &TypeName,
oid: &ObjectId,
) -> Result<Option<CollaborativeObject<T>>, error::Retrieve>
where
T: Evaluate<S>,
S: Store,
{
let tip_refs = storage
.objects(typename, oid)
.map_err(|err| error::Retrieve::Refs { err: Box::new(err) })?;
ChangeGraph::load(storage, tip_refs.iter(), typename, oid)
.map(|graph| graph.evaluate(storage).map_err(error::Retrieve::evaluate))
.transpose()
}