casper_storage/data_access_layer/
entry_points.rs1use crate::tracking_copy::TrackingCopyError;
2use casper_types::{Digest, EntryPointValue, HashAddr};
3
4#[derive(Debug, Clone, PartialEq, Eq)]
6pub struct EntryPointRequest {
7 state_hash: Digest,
8 entry_point_name: String,
9 contract_hash: HashAddr,
10}
11
12impl EntryPointRequest {
13 pub fn new(state_hash: Digest, entry_point_name: String, contract_hash: HashAddr) -> Self {
15 EntryPointRequest {
16 state_hash,
17 entry_point_name,
18 contract_hash,
19 }
20 }
21
22 pub fn state_hash(&self) -> Digest {
24 self.state_hash
25 }
26
27 pub fn entry_point_name(&self) -> &str {
29 &self.entry_point_name
30 }
31
32 pub fn contract_hash(&self) -> HashAddr {
34 self.contract_hash
35 }
36}
37
38impl From<EntryPointExistsRequest> for EntryPointRequest {
39 fn from(value: EntryPointExistsRequest) -> Self {
40 EntryPointRequest {
41 state_hash: value.state_hash,
42 entry_point_name: value.entry_point_name,
43 contract_hash: value.contract_hash,
44 }
45 }
46}
47
48#[derive(Debug)]
50pub enum EntryPointResult {
51 RootNotFound,
53 ValueNotFound(String),
55 Success {
57 entry_point: EntryPointValue,
59 },
60 Failure(TrackingCopyError),
62}
63
64#[derive(Debug, Clone, PartialEq, Eq)]
66pub struct EntryPointExistsRequest {
67 state_hash: Digest,
68 entry_point_name: String,
69 contract_hash: HashAddr,
70}
71
72impl EntryPointExistsRequest {
73 pub fn new(state_hash: Digest, entry_point_name: String, contract_hash: HashAddr) -> Self {
75 EntryPointExistsRequest {
76 state_hash,
77 entry_point_name,
78 contract_hash,
79 }
80 }
81
82 pub fn state_hash(&self) -> Digest {
84 self.state_hash
85 }
86
87 pub fn entry_point_name(&self) -> &str {
89 &self.entry_point_name
90 }
91
92 pub fn contract_hash(&self) -> HashAddr {
94 self.contract_hash
95 }
96}
97
98#[derive(Debug)]
100pub enum EntryPointExistsResult {
101 RootNotFound,
103 ValueNotFound(String),
105 Success,
107 Failure(TrackingCopyError),
109}
110
111impl EntryPointExistsResult {
112 pub fn is_success(self) -> bool {
114 matches!(self, Self::Success { .. })
115 }
116}