wasmlib/coreblob/
params.rs

1// Copyright 2020 IOTA Stiftung
2// SPDX-License-Identifier: Apache-2.0
3
4// (Re-)generated by schema tool
5// >>>> DO NOT CHANGE THIS FILE! <<<<
6// Change the schema definition file instead
7
8#![allow(dead_code)]
9#![allow(unused_imports)]
10
11use crate::*;
12use crate::coreblob::*;
13
14#[derive(Clone)]
15pub struct MapStringToImmutableBytes {
16    pub(crate) proxy: Proxy,
17}
18
19impl MapStringToImmutableBytes {
20    pub fn get_bytes(&self, key: &str) -> ScImmutableBytes {
21        ScImmutableBytes::new(self.proxy.key(&string_to_bytes(key)))
22    }
23}
24
25#[derive(Clone)]
26pub struct ImmutableStoreBlobParams {
27    pub(crate) proxy: Proxy,
28}
29
30impl ImmutableStoreBlobParams {
31    pub fn new() -> ImmutableStoreBlobParams {
32        ImmutableStoreBlobParams {
33            proxy: params_proxy(),
34        }
35    }
36
37    // set of named blobs
38    pub fn blobs(&self) -> MapStringToImmutableBytes {
39        MapStringToImmutableBytes { proxy: self.proxy.clone() }
40    }
41
42    // description of progBinary
43    pub fn description(&self) -> ScImmutableString {
44        ScImmutableString::new(self.proxy.root(PARAM_DESCRIPTION))
45    }
46
47    // smart contract program binary code
48    pub fn prog_binary(&self) -> ScImmutableBytes {
49        ScImmutableBytes::new(self.proxy.root(PARAM_PROG_BINARY))
50    }
51
52    // VM type that must be used to run progBinary
53    pub fn vm_type(&self) -> ScImmutableString {
54        ScImmutableString::new(self.proxy.root(PARAM_VM_TYPE))
55    }
56}
57
58#[derive(Clone)]
59pub struct MapStringToMutableBytes {
60    pub(crate) proxy: Proxy,
61}
62
63impl MapStringToMutableBytes {
64    pub fn clear(&self) {
65        self.proxy.clear_map();
66    }
67
68    pub fn get_bytes(&self, key: &str) -> ScMutableBytes {
69        ScMutableBytes::new(self.proxy.key(&string_to_bytes(key)))
70    }
71}
72
73#[derive(Clone)]
74pub struct MutableStoreBlobParams {
75    pub(crate) proxy: Proxy,
76}
77
78impl MutableStoreBlobParams {
79    // set of named blobs
80    pub fn blobs(&self) -> MapStringToMutableBytes {
81        MapStringToMutableBytes { proxy: self.proxy.clone() }
82    }
83
84    // description of progBinary
85    pub fn description(&self) -> ScMutableString {
86        ScMutableString::new(self.proxy.root(PARAM_DESCRIPTION))
87    }
88
89    // smart contract program binary code
90    pub fn prog_binary(&self) -> ScMutableBytes {
91        ScMutableBytes::new(self.proxy.root(PARAM_PROG_BINARY))
92    }
93
94    // VM type that must be used to run progBinary
95    pub fn vm_type(&self) -> ScMutableString {
96        ScMutableString::new(self.proxy.root(PARAM_VM_TYPE))
97    }
98}
99
100#[derive(Clone)]
101pub struct ImmutableGetBlobFieldParams {
102    pub(crate) proxy: Proxy,
103}
104
105impl ImmutableGetBlobFieldParams {
106    pub fn new() -> ImmutableGetBlobFieldParams {
107        ImmutableGetBlobFieldParams {
108            proxy: params_proxy(),
109        }
110    }
111
112    // blob name
113    pub fn field(&self) -> ScImmutableString {
114        ScImmutableString::new(self.proxy.root(PARAM_FIELD))
115    }
116
117    // blob set
118    pub fn hash(&self) -> ScImmutableHash {
119        ScImmutableHash::new(self.proxy.root(PARAM_HASH))
120    }
121}
122
123#[derive(Clone)]
124pub struct MutableGetBlobFieldParams {
125    pub(crate) proxy: Proxy,
126}
127
128impl MutableGetBlobFieldParams {
129    // blob name
130    pub fn field(&self) -> ScMutableString {
131        ScMutableString::new(self.proxy.root(PARAM_FIELD))
132    }
133
134    // blob set
135    pub fn hash(&self) -> ScMutableHash {
136        ScMutableHash::new(self.proxy.root(PARAM_HASH))
137    }
138}
139
140#[derive(Clone)]
141pub struct ImmutableGetBlobInfoParams {
142    pub(crate) proxy: Proxy,
143}
144
145impl ImmutableGetBlobInfoParams {
146    pub fn new() -> ImmutableGetBlobInfoParams {
147        ImmutableGetBlobInfoParams {
148            proxy: params_proxy(),
149        }
150    }
151
152    // blob set
153    pub fn hash(&self) -> ScImmutableHash {
154        ScImmutableHash::new(self.proxy.root(PARAM_HASH))
155    }
156}
157
158#[derive(Clone)]
159pub struct MutableGetBlobInfoParams {
160    pub(crate) proxy: Proxy,
161}
162
163impl MutableGetBlobInfoParams {
164    // blob set
165    pub fn hash(&self) -> ScMutableHash {
166        ScMutableHash::new(self.proxy.root(PARAM_HASH))
167    }
168}