casper_storage/data_access_layer/
addressable_entity.rs1use crate::tracking_copy::TrackingCopyError;
2use casper_types::{AddressableEntity, Digest, Key};
3
4#[derive(Debug, Clone, PartialEq, Eq)]
6pub struct AddressableEntityRequest {
7 state_hash: Digest,
8 key: Key,
9}
10
11impl AddressableEntityRequest {
12 pub fn new(state_hash: Digest, key: Key) -> Self {
14 AddressableEntityRequest { state_hash, key }
15 }
16
17 pub fn state_hash(&self) -> Digest {
19 self.state_hash
20 }
21
22 pub fn key(&self) -> Key {
24 self.key
25 }
26}
27
28#[derive(Debug)]
30pub enum AddressableEntityResult {
31 RootNotFound,
33 ValueNotFound(String),
35 Success {
37 entity: AddressableEntity,
39 },
40 Failure(TrackingCopyError),
42}
43
44impl AddressableEntityResult {
45 pub fn into_option(self) -> Option<AddressableEntity> {
47 if let Self::Success { entity } = self {
48 Some(entity)
49 } else {
50 None
51 }
52 }
53}