viceroy_lib/component/
handles.rs

1use crate::wiggle_abi::types::*;
2
3/// Macro which provides the common implementation of a resource type.
4macro_rules! resource_impl {
5    ($entity:ident, $bindings_type:path) => {
6        // Add convenient functions for converting to and from `Resource`s.
7        impl From<$crate::component::component::Resource<$bindings_type>> for $entity {
8            fn from(resource: $crate::component::component::Resource<$bindings_type>) -> Self {
9                Self::from(resource.rep())
10            }
11        }
12
13        impl From<$entity> for $crate::component::component::Resource<$bindings_type> {
14            fn from(entity: $entity) -> $crate::component::component::Resource<$bindings_type> {
15                crate::component::component::Resource::new_own(entity.into())
16            }
17        }
18    };
19}
20
21resource_impl!(
22    ConfigStoreHandle,
23    crate::component::bindings::fastly::compute::config_store::Store
24);
25
26resource_impl!(
27    DictionaryHandle,
28    crate::component::bindings::fastly::compute::dictionary::Dictionary
29);
30
31resource_impl!(
32    AsyncItemHandle,
33    crate::component::bindings::fastly::compute::async_io::Pollable
34);
35
36resource_impl!(
37    RequestHandle,
38    crate::component::bindings::fastly::compute::http_req::Request
39);
40
41resource_impl!(
42    ResponseHandle,
43    crate::component::bindings::fastly::compute::http_resp::Response
44);
45
46resource_impl!(
47    BodyHandle,
48    crate::component::bindings::fastly::compute::http_body::Body
49);
50
51resource_impl!(
52    PendingRequestHandle,
53    crate::component::bindings::fastly::compute::http_req::PendingRequest
54);
55
56resource_impl!(
57    EndpointHandle,
58    crate::component::bindings::fastly::compute::log::Endpoint
59);
60
61resource_impl!(
62    KvStoreLookupHandle,
63    crate::component::bindings::fastly::compute::kv_store::PendingLookup
64);
65
66resource_impl!(
67    KvStoreInsertHandle,
68    crate::component::bindings::fastly::compute::kv_store::PendingInsert
69);
70
71resource_impl!(
72    KvStoreDeleteHandle,
73    crate::component::bindings::fastly::compute::kv_store::PendingDelete
74);
75
76resource_impl!(
77    KvStoreListHandle,
78    crate::component::bindings::fastly::compute::kv_store::PendingList
79);
80
81resource_impl!(
82    KvStoreHandle,
83    crate::component::bindings::fastly::compute::kv_store::Store
84);
85
86resource_impl!(
87    SecretStoreHandle,
88    crate::component::bindings::fastly::compute::secret_store::Store
89);
90
91resource_impl!(
92    SecretHandle,
93    crate::component::bindings::fastly::compute::secret_store::Secret
94);
95
96resource_impl!(
97    CacheHandle,
98    crate::component::bindings::fastly::compute::cache::Entry
99);
100
101resource_impl!(
102    CacheBusyHandle,
103    crate::component::bindings::fastly::compute::cache::PendingEntry
104);
105
106resource_impl!(
107    CacheReplaceHandle,
108    crate::component::bindings::fastly::compute::cache::ReplaceEntry
109);
110
111resource_impl!(
112    HttpCacheHandle,
113    crate::component::bindings::fastly::compute::http_cache::Entry
114);
115
116resource_impl!(
117    AclHandle,
118    crate::component::bindings::fastly::compute::acl::Acl
119);
120
121resource_impl!(
122    RequestPromiseHandle,
123    crate::component::bindings::fastly::compute::http_downstream::PendingRequest
124);