multiversx_sc/api/external_view/
ev_wrapper.rs1use core::marker::PhantomData;
2
3use crate::api::{
4 BlockchainApi, CallTypeApi, CallValueApi, CryptoApi, EndpointArgumentApi, EndpointFinishApi,
5 ErrorApi, HandleTypeInfo, LogApi, ManagedTypeApi, PrintApi, SendApi, StaticVarApi,
6 StorageMapperApi, StorageWriteApi, VMApi,
7};
8
9#[derive(Clone)]
10pub struct ExternalViewApi<A: VMApi> {
11 _phantom: PhantomData<A>,
12}
13
14impl<A: VMApi> ExternalViewApi<A> {
15 pub(super) fn new() -> Self {
16 ExternalViewApi {
17 _phantom: PhantomData,
18 }
19 }
20}
21
22impl<A> HandleTypeInfo for ExternalViewApi<A>
23where
24 A: VMApi,
25{
26 type ManagedBufferHandle = <A as HandleTypeInfo>::ManagedBufferHandle;
27
28 type BigIntHandle = <A as HandleTypeInfo>::BigIntHandle;
29
30 type BigFloatHandle = <A as HandleTypeInfo>::BigFloatHandle;
31
32 type EllipticCurveHandle = <A as HandleTypeInfo>::EllipticCurveHandle;
33
34 type ManagedMapHandle = <A as HandleTypeInfo>::ManagedMapHandle;
35}
36
37impl<A> BlockchainApi for ExternalViewApi<A>
38where
39 A: VMApi,
40{
41 type BlockchainApiImpl = A::BlockchainApiImpl;
42
43 fn blockchain_api_impl() -> A::BlockchainApiImpl {
44 A::blockchain_api_impl()
45 }
46}
47
48impl<A> CallValueApi for ExternalViewApi<A>
49where
50 A: VMApi,
51{
52 type CallValueApiImpl = A::CallValueApiImpl;
53
54 fn call_value_api_impl() -> Self::CallValueApiImpl {
55 A::call_value_api_impl()
56 }
57}
58
59impl<A> CryptoApi for ExternalViewApi<A>
60where
61 A: VMApi,
62{
63 type CryptoApiImpl = A::CryptoApiImpl;
64
65 fn crypto_api_impl() -> Self::CryptoApiImpl {
66 A::crypto_api_impl()
67 }
68}
69
70impl<A> EndpointArgumentApi for ExternalViewApi<A>
71where
72 A: VMApi,
73{
74 type EndpointArgumentApiImpl = A::EndpointArgumentApiImpl;
75
76 fn argument_api_impl() -> Self::EndpointArgumentApiImpl {
77 A::argument_api_impl()
78 }
79}
80
81impl<A> EndpointFinishApi for ExternalViewApi<A>
82where
83 A: VMApi,
84{
85 type EndpointFinishApiImpl = A::EndpointFinishApiImpl;
86
87 fn finish_api_impl() -> Self::EndpointFinishApiImpl {
88 A::finish_api_impl()
89 }
90}
91
92impl<A> ErrorApi for super::ExternalViewApi<A>
93where
94 A: VMApi,
95{
96 type ErrorApiImpl = A::ErrorApiImpl;
97
98 fn error_api_impl() -> Self::ErrorApiImpl {
99 A::error_api_impl()
100 }
101}
102
103impl<A> LogApi for ExternalViewApi<A>
104where
105 A: VMApi,
106{
107 type LogApiImpl = A::LogApiImpl;
108
109 fn log_api_impl() -> Self::LogApiImpl {
110 A::log_api_impl()
111 }
112}
113
114impl<A> ManagedTypeApi for ExternalViewApi<A>
115where
116 A: VMApi,
117{
118 type ManagedTypeApiImpl = A::ManagedTypeApiImpl;
119
120 fn managed_type_impl() -> Self::ManagedTypeApiImpl {
121 A::managed_type_impl()
122 }
123}
124
125impl<A> PrintApi for ExternalViewApi<A>
126where
127 A: VMApi,
128{
129 type PrintApiImpl = A::PrintApiImpl;
130
131 fn print_api_impl() -> Self::PrintApiImpl {
132 A::print_api_impl()
133 }
134}
135
136impl<A> SendApi for ExternalViewApi<A>
137where
138 A: VMApi,
139{
140 type SendApiImpl = A::SendApiImpl;
141
142 fn send_api_impl() -> Self::SendApiImpl {
143 A::send_api_impl()
144 }
145}
146
147impl<A> StaticVarApi for ExternalViewApi<A>
148where
149 A: VMApi,
150{
151 type StaticVarApiImpl = A::StaticVarApiImpl;
152
153 fn static_var_api_impl() -> Self::StaticVarApiImpl {
154 A::static_var_api_impl()
155 }
156}
157
158impl<A> StorageWriteApi for ExternalViewApi<A>
159where
160 A: VMApi,
161{
162 type StorageWriteApiImpl = A::StorageWriteApiImpl;
163
164 fn storage_write_api_impl() -> Self::StorageWriteApiImpl {
165 A::storage_write_api_impl()
166 }
167}
168
169impl<A> CallTypeApi for ExternalViewApi<A> where A: VMApi {}
170
171impl<A> StorageMapperApi for ExternalViewApi<A> where A: VMApi {}
172
173impl<A> VMApi for ExternalViewApi<A>
174where
175 A: VMApi,
176{
177 fn external_view_init_override() -> bool {
178 true
179 }
180}
181
182impl<A> PartialEq for ExternalViewApi<A>
183where
184 A: VMApi,
185{
186 fn eq(&self, _: &Self) -> bool {
187 true
188 }
189}
190
191impl<A> Eq for ExternalViewApi<A> where A: VMApi {}