use super::*;
impl<A: Aleo> Value<A> {
pub fn find<A0: Into<Access<A>> + Clone + Debug>(&self, path: &[A0]) -> Result<Self> {
match self {
Self::Plaintext(plaintext) => Ok(Self::Plaintext(plaintext.find(path)?)),
Self::Record(record) => {
let entry = record.find(path)?;
match entry {
Entry::Constant(plaintext) => Ok(Self::Plaintext(plaintext)),
Entry::Public(plaintext) => Ok(Self::Plaintext(plaintext)),
Entry::Private(plaintext) => Ok(Self::Plaintext(plaintext)),
}
}
Self::Future(future) => Ok(future.find(path)?),
Self::DynamicRecord(dynamic_record) => Ok(dynamic_record.find(path)?),
Self::DynamicFuture(..) => bail!("Cannot invoke `find` on a dynamic future value"),
}
}
}