ic-mops 0.8.3 → 0.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/.mops/base@0.7.4/LICENSE +208 -0
  2. package/.mops/base@0.7.4/README.md +64 -0
  3. package/.mops/base@0.7.4/mops.toml +5 -0
  4. package/.mops/base@0.7.4/src/Array.mo +686 -0
  5. package/.mops/base@0.7.4/src/AssocList.mo +203 -0
  6. package/.mops/base@0.7.4/src/Blob.mo +55 -0
  7. package/.mops/base@0.7.4/src/Bool.mo +44 -0
  8. package/.mops/base@0.7.4/src/Buffer.mo +1937 -0
  9. package/.mops/base@0.7.4/src/CertifiedData.mo +29 -0
  10. package/.mops/base@0.7.4/src/Char.mo +67 -0
  11. package/.mops/base@0.7.4/src/Debug.mo +15 -0
  12. package/.mops/base@0.7.4/src/Deque.mo +75 -0
  13. package/.mops/base@0.7.4/src/Error.mo +41 -0
  14. package/.mops/base@0.7.4/src/ExperimentalCycles.mo +51 -0
  15. package/.mops/base@0.7.4/src/ExperimentalInternetComputer.mo +36 -0
  16. package/.mops/base@0.7.4/src/ExperimentalStableMemory.mo +121 -0
  17. package/.mops/base@0.7.4/src/Float.mo +150 -0
  18. package/.mops/base@0.7.4/src/Func.mo +38 -0
  19. package/.mops/base@0.7.4/src/Hash.mo +83 -0
  20. package/.mops/base@0.7.4/src/HashMap.mo +229 -0
  21. package/.mops/base@0.7.4/src/Heap.mo +113 -0
  22. package/.mops/base@0.7.4/src/Int.mo +150 -0
  23. package/.mops/base@0.7.4/src/Int16.mo +159 -0
  24. package/.mops/base@0.7.4/src/Int32.mo +160 -0
  25. package/.mops/base@0.7.4/src/Int64.mo +161 -0
  26. package/.mops/base@0.7.4/src/Int8.mo +160 -0
  27. package/.mops/base@0.7.4/src/Iter.mo +220 -0
  28. package/.mops/base@0.7.4/src/IterType.mo +7 -0
  29. package/.mops/base@0.7.4/src/List.mo +433 -0
  30. package/.mops/base@0.7.4/src/Nat.mo +75 -0
  31. package/.mops/base@0.7.4/src/Nat16.mo +146 -0
  32. package/.mops/base@0.7.4/src/Nat32.mo +146 -0
  33. package/.mops/base@0.7.4/src/Nat64.mo +146 -0
  34. package/.mops/base@0.7.4/src/Nat8.mo +146 -0
  35. package/.mops/base@0.7.4/src/None.mo +19 -0
  36. package/.mops/base@0.7.4/src/Option.mo +160 -0
  37. package/.mops/base@0.7.4/src/Order.mo +46 -0
  38. package/.mops/base@0.7.4/src/Prelude.mo +33 -0
  39. package/.mops/base@0.7.4/src/Principal.mo +58 -0
  40. package/.mops/base@0.7.4/src/RBTree.mo +218 -0
  41. package/.mops/base@0.7.4/src/Random.mo +188 -0
  42. package/.mops/base@0.7.4/src/Result.mo +210 -0
  43. package/.mops/base@0.7.4/src/Stack.mo +40 -0
  44. package/.mops/base@0.7.4/src/Text.mo +615 -0
  45. package/.mops/base@0.7.4/src/Time.mo +37 -0
  46. package/.mops/base@0.7.4/src/Trie.mo +1200 -0
  47. package/.mops/base@0.7.4/src/TrieMap.mo +180 -0
  48. package/.mops/base@0.7.4/src/TrieSet.mo +97 -0
  49. package/.mops/base@0.8.3/LICENSE +208 -0
  50. package/.mops/base@0.8.3/README.md +64 -0
  51. package/.mops/base@0.8.3/mops.toml +6 -0
  52. package/.mops/base@0.8.3/src/Array.mo +717 -0
  53. package/.mops/base@0.8.3/src/AssocList.mo +404 -0
  54. package/.mops/base@0.8.3/src/Blob.mo +212 -0
  55. package/.mops/base@0.8.3/src/Bool.mo +44 -0
  56. package/.mops/base@0.8.3/src/Buffer.mo +2660 -0
  57. package/.mops/base@0.8.3/src/CertifiedData.mo +53 -0
  58. package/.mops/base@0.8.3/src/Char.mo +65 -0
  59. package/.mops/base@0.8.3/src/Debug.mo +56 -0
  60. package/.mops/base@0.8.3/src/Deque.mo +243 -0
  61. package/.mops/base@0.8.3/src/Error.mo +68 -0
  62. package/.mops/base@0.8.3/src/ExperimentalCycles.mo +151 -0
  63. package/.mops/base@0.8.3/src/ExperimentalInternetComputer.mo +60 -0
  64. package/.mops/base@0.8.3/src/ExperimentalStableMemory.mo +348 -0
  65. package/.mops/base@0.8.3/src/Float.mo +843 -0
  66. package/.mops/base@0.8.3/src/Func.mo +46 -0
  67. package/.mops/base@0.8.3/src/Hash.mo +82 -0
  68. package/.mops/base@0.8.3/src/HashMap.mo +457 -0
  69. package/.mops/base@0.8.3/src/Heap.mo +233 -0
  70. package/.mops/base@0.8.3/src/Int.mo +365 -0
  71. package/.mops/base@0.8.3/src/Int16.mo +521 -0
  72. package/.mops/base@0.8.3/src/Int32.mo +522 -0
  73. package/.mops/base@0.8.3/src/Int64.mo +522 -0
  74. package/.mops/base@0.8.3/src/Int8.mo +522 -0
  75. package/.mops/base@0.8.3/src/Iter.mo +227 -0
  76. package/.mops/base@0.8.3/src/IterType.mo +7 -0
  77. package/.mops/base@0.8.3/src/List.mo +930 -0
  78. package/.mops/base@0.8.3/src/Nat.mo +305 -0
  79. package/.mops/base@0.8.3/src/Nat16.mo +144 -0
  80. package/.mops/base@0.8.3/src/Nat32.mo +144 -0
  81. package/.mops/base@0.8.3/src/Nat64.mo +144 -0
  82. package/.mops/base@0.8.3/src/Nat8.mo +144 -0
  83. package/.mops/base@0.8.3/src/None.mo +19 -0
  84. package/.mops/base@0.8.3/src/Option.mo +154 -0
  85. package/.mops/base@0.8.3/src/Order.mo +46 -0
  86. package/.mops/base@0.8.3/src/Prelude.mo +33 -0
  87. package/.mops/base@0.8.3/src/Principal.mo +249 -0
  88. package/.mops/base@0.8.3/src/RBTree.mo +681 -0
  89. package/.mops/base@0.8.3/src/Random.mo +270 -0
  90. package/.mops/base@0.8.3/src/Result.mo +209 -0
  91. package/.mops/base@0.8.3/src/Stack.mo +93 -0
  92. package/.mops/base@0.8.3/src/Text.mo +761 -0
  93. package/.mops/base@0.8.3/src/Time.mo +36 -0
  94. package/.mops/base@0.8.3/src/Timer.mo +62 -0
  95. package/.mops/base@0.8.3/src/Trie.mo +1603 -0
  96. package/.mops/base@0.8.3/src/TrieMap.mo +392 -0
  97. package/.mops/base@0.8.3/src/TrieSet.mo +148 -0
  98. package/mops.js +1 -1
  99. package/network.txt +1 -0
  100. package/package.json +2 -2
@@ -0,0 +1,60 @@
1
+ /// Low-level interface to the Internet Computer.
2
+ ///
3
+ /// **WARNING:** This low-level API is **experimental** and likely to change or even disappear.
4
+
5
+ import Prim "mo:⛔";
6
+
7
+ module {
8
+
9
+ /// Calls ``canister``'s update or query function, `name`, with the binary contents of `data` as IC argument.
10
+ /// Returns the response to the call, an IC _reply_ or _reject_, as a Motoko future:
11
+ ///
12
+ /// * The message data of an IC reply determines the binary contents of `reply`.
13
+ /// * The error code and textual message data of an IC reject determines the future's `Error` value.
14
+ ///
15
+ /// Note: `call` is an asynchronous function and can only be applied in an asynchronous context.
16
+ ///
17
+ /// Example:
18
+ /// ```motoko no-repl
19
+ /// import IC "mo:base/ExperimentalInternetComputer";
20
+ /// import Principal "mo:base/Principal";
21
+ ///
22
+ /// let ledger = Principal.fromText("ryjl3-tyaaa-aaaaa-aaaba-cai");
23
+ /// let method = "decimals";
24
+ /// let input = ();
25
+ /// type OutputType = { decimals : Nat32 };
26
+ ///
27
+ /// let rawReply = await IC.call(ledger, method, to_candid(input)); // serialized Candid
28
+ /// let output : ?OutputType = from_candid(rawReply); // { decimals = 8 }
29
+ /// ```
30
+ ///
31
+ /// [Learn more about Candid serialization](https://internetcomputer.org/docs/current/developer-docs/build/cdks/motoko-dfinity/language-manual#candid-serialization)
32
+ public let call : (canister : Principal, name : Text, data : Blob) -> async (reply : Blob) = Prim.call_raw;
33
+
34
+ /// Given computation, `comp`, counts the number of actual and (for IC system calls) notional WebAssembly
35
+ /// instructions performed during the execution of `comp()`.
36
+ ///
37
+ /// More precisely, returns the difference between the state of the IC instruction counter (_performance counter_ `0`) before and after executing `comp()`
38
+ /// (see [Performance Counter](https://internetcomputer.org/docs/current/references/ic-interface-spec#system-api-performance-counter)).
39
+ ///
40
+ /// NB: `countInstructions(comp)` will _not_ account for any deferred garbage collection costs incurred by `comp()`.
41
+ ///
42
+ /// Example:
43
+ /// ```motoko no-repl
44
+ /// import IC "mo:base/ExperimentalInternetComputer";
45
+ ///
46
+ /// let count = IC.countInstructions(func() {
47
+ /// // ...
48
+ /// });
49
+ /// ```
50
+ public func countInstructions(comp : () -> ()) : Nat64 {
51
+ let init = Prim.performanceCounter(0);
52
+ let pre = Prim.performanceCounter(0);
53
+ comp();
54
+ let post = Prim.performanceCounter(0);
55
+ // performance_counter costs around 200 extra instructions, we perform an empty measurement to decide the overhead
56
+ let overhead = pre - init;
57
+ post - pre - overhead
58
+ }
59
+
60
+ }
@@ -0,0 +1,348 @@
1
+ /// Byte-level access to (virtual) _stable memory_.
2
+ ///
3
+ /// **WARNING**: As its name suggests, this library is **experimental**, subject to change
4
+ /// and may be replaced by safer alternatives in later versions of Motoko.
5
+ /// Use at your own risk and discretion.
6
+ ///
7
+ /// This is a lightweight abstraction over IC _stable memory_ and supports persisting
8
+ /// raw binary data across Motoko upgrades.
9
+ /// Use of this module is fully compatible with Motoko's use of
10
+ /// _stable variables_, whose persistence mechanism also uses (real) IC stable memory internally, but does not interfere with this API.
11
+ ///
12
+ /// Memory is allocated, using `grow(pages)`, sequentially and on demand, in units of 64KiB pages, starting with 0 allocated pages.
13
+ /// New pages are zero initialized.
14
+ /// Growth is capped by a soft limit on page count controlled by compile-time flag
15
+ /// `--max-stable-pages <n>` (the default is 65536, or 4GiB).
16
+ ///
17
+ /// Each `load` operation loads from byte address `offset` in little-endian
18
+ /// format using the natural bit-width of the type in question.
19
+ /// The operation traps if attempting to read beyond the current stable memory size.
20
+ ///
21
+ /// Each `store` operation stores to byte address `offset` in little-endian format using the natural bit-width of the type in question.
22
+ /// The operation traps if attempting to write beyond the current stable memory size.
23
+ ///
24
+ /// Text values can be handled by using `Text.decodeUtf8` and `Text.encodeUtf8`, in conjunction with `loadBlob` and `storeBlob`.
25
+ ///
26
+ /// The current page allocation and page contents is preserved across upgrades.
27
+ ///
28
+ /// NB: The IC's actual stable memory size (`ic0.stable_size`) may exceed the
29
+ /// page size reported by Motoko function `size()`.
30
+ /// This (and the cap on growth) are to accommodate Motoko's stable variables.
31
+ /// Applications that plan to use Motoko stable variables sparingly or not at all can
32
+ /// increase `--max-stable-pages` as desired, approaching the IC maximum (initially 8GiB, then 32Gib, currently 48Gib).
33
+ /// All applications should reserve at least one page for stable variable data, even when no stable variables are used.
34
+ ///
35
+ /// Usage:
36
+ /// ```motoko no-repl
37
+ /// import StableMemory "mo:base/ExperimentalStableMemory";
38
+ /// ```
39
+
40
+ import Prim "mo:⛔";
41
+
42
+ module {
43
+
44
+ /// Current size of the stable memory, in pages.
45
+ /// Each page is 64KiB (65536 bytes).
46
+ /// Initially `0`.
47
+ /// Preserved across upgrades, together with contents of allocated
48
+ /// stable memory.
49
+ ///
50
+ /// Example:
51
+ /// ```motoko no-repl
52
+ /// let beforeSize = StableMemory.size();
53
+ /// ignore StableMemory.grow(10);
54
+ /// let afterSize = StableMemory.size();
55
+ /// afterSize - beforeSize // => 10
56
+ /// ```
57
+ public let size : () -> (pages : Nat64) = Prim.stableMemorySize;
58
+
59
+ /// Grow current `size` of stable memory by the given number of pages.
60
+ /// Each page is 64KiB (65536 bytes).
61
+ /// Returns the previous `size` when able to grow.
62
+ /// Returns `0xFFFF_FFFF_FFFF_FFFF` if remaining pages insufficient.
63
+ /// Every new page is zero-initialized, containing byte 0x00 at every offset.
64
+ /// Function `grow` is capped by a soft limit on `size` controlled by compile-time flag
65
+ /// `--max-stable-pages <n>` (the default is 65536, or 4GiB).
66
+ ///
67
+ /// Example:
68
+ /// ```motoko no-repl
69
+ /// import Error "mo:base/Error";
70
+ ///
71
+ /// let beforeSize = StableMemory.grow(10);
72
+ /// if (beforeSize == 0xFFFF_FFFF_FFFF_FFFF) {
73
+ /// throw Error.reject("Out of memory");
74
+ /// };
75
+ /// let afterSize = StableMemory.size();
76
+ /// afterSize - beforeSize // => 10
77
+ /// ```
78
+ public let grow : (newPages : Nat64) -> (oldPages : Nat64) = Prim.stableMemoryGrow;
79
+
80
+ /// Returns a query that, when called, returns the number of bytes of (real) IC stable memory that would be
81
+ /// occupied by persisting its current stable variables before an upgrade.
82
+ /// This function may be used to monitor or limit real stable memory usage.
83
+ /// The query computes the estimate by running the first half of an upgrade, including any `preupgrade` system method.
84
+ /// Like any other query, its state changes are discarded so no actual upgrade (or other state change) takes place.
85
+ /// The query can only be called by the enclosing actor and will trap for other callers.
86
+ ///
87
+ /// Example:
88
+ /// ```motoko no-repl
89
+ /// actor {
90
+ /// stable var state = "";
91
+ /// public func example() : async Text {
92
+ /// let memoryUsage = StableMemory.stableVarQuery();
93
+ /// let beforeSize = (await memoryUsage()).size;
94
+ /// state #= "abcdefghijklmnopqrstuvwxyz";
95
+ /// let afterSize = (await memoryUsage()).size;
96
+ /// debug_show (afterSize - beforeSize)
97
+ /// };
98
+ /// };
99
+ /// ```
100
+ public let stableVarQuery : () -> (shared query () -> async { size : Nat64 }) = Prim.stableVarQuery;
101
+
102
+ /// Loads a `Nat32` value from stable memory at the given `offset`.
103
+ /// Traps on an out-of-bounds access.
104
+ ///
105
+ /// Example:
106
+ /// ```motoko no-repl
107
+ /// let offset = 0;
108
+ /// let value = 123;
109
+ /// StableMemory.storeNat32(offset, value);
110
+ /// StableMemory.loadNat32(offset) // => 123
111
+ /// ```
112
+ public let loadNat32 : (offset : Nat64) -> Nat32 = Prim.stableMemoryLoadNat32;
113
+
114
+ /// Stores a `Nat32` value in stable memory at the given `offset`.
115
+ /// Traps on an out-of-bounds access.
116
+ ///
117
+ /// Example:
118
+ /// ```motoko no-repl
119
+ /// let offset = 0;
120
+ /// let value = 123;
121
+ /// StableMemory.storeNat32(offset, value);
122
+ /// StableMemory.loadNat32(offset) // => 123
123
+ /// ```
124
+ public let storeNat32 : (offset : Nat64, value : Nat32) -> () = Prim.stableMemoryStoreNat32;
125
+
126
+ /// Loads a `Nat8` value from stable memory at the given `offset`.
127
+ /// Traps on an out-of-bounds access.
128
+ ///
129
+ /// Example:
130
+ /// ```motoko no-repl
131
+ /// let offset = 0;
132
+ /// let value = 123;
133
+ /// StableMemory.storeNat8(offset, value);
134
+ /// StableMemory.loadNat8(offset) // => 123
135
+ /// ```
136
+ public let loadNat8 : (offset : Nat64) -> Nat8 = Prim.stableMemoryLoadNat8;
137
+
138
+ /// Stores a `Nat8` value in stable memory at the given `offset`.
139
+ /// Traps on an out-of-bounds access.
140
+ ///
141
+ /// Example:
142
+ /// ```motoko no-repl
143
+ /// let offset = 0;
144
+ /// let value = 123;
145
+ /// StableMemory.storeNat8(offset, value);
146
+ /// StableMemory.loadNat8(offset) // => 123
147
+ /// ```
148
+ public let storeNat8 : (offset : Nat64, value : Nat8) -> () = Prim.stableMemoryStoreNat8;
149
+
150
+ /// Loads a `Nat16` value from stable memory at the given `offset`.
151
+ /// Traps on an out-of-bounds access.
152
+ ///
153
+ /// Example:
154
+ /// ```motoko no-repl
155
+ /// let offset = 0;
156
+ /// let value = 123;
157
+ /// StableMemory.storeNat16(offset, value);
158
+ /// StableMemory.loadNat16(offset) // => 123
159
+ /// ```
160
+ public let loadNat16 : (offset : Nat64) -> Nat16 = Prim.stableMemoryLoadNat16;
161
+
162
+ /// Stores a `Nat16` value in stable memory at the given `offset`.
163
+ /// Traps on an out-of-bounds access.
164
+ ///
165
+ /// Example:
166
+ /// ```motoko no-repl
167
+ /// let offset = 0;
168
+ /// let value = 123;
169
+ /// StableMemory.storeNat16(offset, value);
170
+ /// StableMemory.loadNat16(offset) // => 123
171
+ /// ```
172
+ public let storeNat16 : (offset : Nat64, value : Nat16) -> () = Prim.stableMemoryStoreNat16;
173
+
174
+ /// Loads a `Nat64` value from stable memory at the given `offset`.
175
+ /// Traps on an out-of-bounds access.
176
+ ///
177
+ /// Example:
178
+ /// ```motoko no-repl
179
+ /// let offset = 0;
180
+ /// let value = 123;
181
+ /// StableMemory.storeNat64(offset, value);
182
+ /// StableMemory.loadNat64(offset) // => 123
183
+ /// ```
184
+ public let loadNat64 : (offset : Nat64) -> Nat64 = Prim.stableMemoryLoadNat64;
185
+
186
+ /// Stores a `Nat64` value in stable memory at the given `offset`.
187
+ /// Traps on an out-of-bounds access.
188
+ ///
189
+ /// Example:
190
+ /// ```motoko no-repl
191
+ /// let offset = 0;
192
+ /// let value = 123;
193
+ /// StableMemory.storeNat64(offset, value);
194
+ /// StableMemory.loadNat64(offset) // => 123
195
+ /// ```
196
+ public let storeNat64 : (offset : Nat64, value : Nat64) -> () = Prim.stableMemoryStoreNat64;
197
+
198
+ /// Loads an `Int32` value from stable memory at the given `offset`.
199
+ /// Traps on an out-of-bounds access.
200
+ ///
201
+ /// Example:
202
+ /// ```motoko no-repl
203
+ /// let offset = 0;
204
+ /// let value = 123;
205
+ /// StableMemory.storeInt32(offset, value);
206
+ /// StableMemory.loadInt32(offset) // => 123
207
+ /// ```
208
+ public let loadInt32 : (offset : Nat64) -> Int32 = Prim.stableMemoryLoadInt32;
209
+
210
+ /// Stores an `Int32` value in stable memory at the given `offset`.
211
+ /// Traps on an out-of-bounds access.
212
+ ///
213
+ /// Example:
214
+ /// ```motoko no-repl
215
+ /// let offset = 0;
216
+ /// let value = 123;
217
+ /// StableMemory.storeInt32(offset, value);
218
+ /// StableMemory.loadInt32(offset) // => 123
219
+ /// ```
220
+ public let storeInt32 : (offset : Nat64, value : Int32) -> () = Prim.stableMemoryStoreInt32;
221
+
222
+ /// Loads an `Int8` value from stable memory at the given `offset`.
223
+ /// Traps on an out-of-bounds access.
224
+ ///
225
+ /// Example:
226
+ /// ```motoko no-repl
227
+ /// let offset = 0;
228
+ /// let value = 123;
229
+ /// StableMemory.storeInt8(offset, value);
230
+ /// StableMemory.loadInt8(offset) // => 123
231
+ /// ```
232
+ public let loadInt8 : (offset : Nat64) -> Int8 = Prim.stableMemoryLoadInt8;
233
+
234
+ /// Stores an `Int8` value in stable memory at the given `offset`.
235
+ /// Traps on an out-of-bounds access.
236
+ ///
237
+ /// Example:
238
+ /// ```motoko no-repl
239
+ /// let offset = 0;
240
+ /// let value = 123;
241
+ /// StableMemory.storeInt8(offset, value);
242
+ /// StableMemory.loadInt8(offset) // => 123
243
+ /// ```
244
+ public let storeInt8 : (offset : Nat64, value : Int8) -> () = Prim.stableMemoryStoreInt8;
245
+
246
+ /// Loads an `Int16` value from stable memory at the given `offset`.
247
+ /// Traps on an out-of-bounds access.
248
+ ///
249
+ /// Example:
250
+ /// ```motoko no-repl
251
+ /// let offset = 0;
252
+ /// let value = 123;
253
+ /// StableMemory.storeInt16(offset, value);
254
+ /// StableMemory.loadInt16(offset) // => 123
255
+ /// ```
256
+ public let loadInt16 : (offset : Nat64) -> Int16 = Prim.stableMemoryLoadInt16;
257
+
258
+ /// Stores an `Int16` value in stable memory at the given `offset`.
259
+ /// Traps on an out-of-bounds access.
260
+ ///
261
+ /// Example:
262
+ /// ```motoko no-repl
263
+ /// let offset = 0;
264
+ /// let value = 123;
265
+ /// StableMemory.storeInt16(offset, value);
266
+ /// StableMemory.loadInt16(offset) // => 123
267
+ /// ```
268
+ public let storeInt16 : (offset : Nat64, value : Int16) -> () = Prim.stableMemoryStoreInt16;
269
+
270
+ /// Loads an `Int64` value from stable memory at the given `offset`.
271
+ /// Traps on an out-of-bounds access.
272
+ ///
273
+ /// Example:
274
+ /// ```motoko no-repl
275
+ /// let offset = 0;
276
+ /// let value = 123;
277
+ /// StableMemory.storeInt64(offset, value);
278
+ /// StableMemory.loadInt64(offset) // => 123
279
+ /// ```
280
+ public let loadInt64 : (offset : Nat64) -> Int64 = Prim.stableMemoryLoadInt64;
281
+
282
+ /// Stores an `Int64` value in stable memory at the given `offset`.
283
+ /// Traps on an out-of-bounds access.
284
+ ///
285
+ /// Example:
286
+ /// ```motoko no-repl
287
+ /// let offset = 0;
288
+ /// let value = 123;
289
+ /// StableMemory.storeInt64(offset, value);
290
+ /// StableMemory.loadInt64(offset) // => 123
291
+ /// ```
292
+ public let storeInt64 : (offset : Nat64, value : Int64) -> () = Prim.stableMemoryStoreInt64;
293
+
294
+ /// Loads a `Float` value from stable memory at the given `offset`.
295
+ /// Traps on an out-of-bounds access.
296
+ ///
297
+ /// Example:
298
+ /// ```motoko no-repl
299
+ /// let offset = 0;
300
+ /// let value = 1.25;
301
+ /// StableMemory.storeFloat(offset, value);
302
+ /// StableMemory.loadFloat(offset) // => 1.25
303
+ /// ```
304
+ public let loadFloat : (offset : Nat64) -> Float = Prim.stableMemoryLoadFloat;
305
+
306
+ /// Stores a `Float` value in stable memory at the given `offset`.
307
+ /// Traps on an out-of-bounds access.
308
+ ///
309
+ /// Example:
310
+ /// ```motoko no-repl
311
+ /// let offset = 0;
312
+ /// let value = 1.25;
313
+ /// StableMemory.storeFloat(offset, value);
314
+ /// StableMemory.loadFloat(offset) // => 1.25
315
+ /// ```
316
+ public let storeFloat : (offset : Nat64, value : Float) -> () = Prim.stableMemoryStoreFloat;
317
+
318
+ /// Load `size` bytes starting from `offset` as a `Blob`.
319
+ /// Traps on an out-of-bounds access.
320
+ ///
321
+ /// Example:
322
+ /// ```motoko no-repl
323
+ /// import Blob "mo:base/Blob";
324
+ ///
325
+ /// let offset = 0;
326
+ /// let value = Blob.fromArray([1, 2, 3]);
327
+ /// let size = value.size();
328
+ /// StableMemory.storeBlob(offset, value);
329
+ /// Blob.toArray(StableMemory.loadBlob(offset, size)) // => [1, 2, 3]
330
+ /// ```
331
+ public let loadBlob : (offset : Nat64, size : Nat) -> Blob = Prim.stableMemoryLoadBlob;
332
+
333
+ /// Write bytes of `blob` beginning at `offset`.
334
+ /// Traps on an out-of-bounds access.
335
+ ///
336
+ /// Example:
337
+ /// ```motoko no-repl
338
+ /// import Blob "mo:base/Blob";
339
+ ///
340
+ /// let offset = 0;
341
+ /// let value = Blob.fromArray([1, 2, 3]);
342
+ /// let size = value.size();
343
+ /// StableMemory.storeBlob(offset, value);
344
+ /// Blob.toArray(StableMemory.loadBlob(offset, size)) // => [1, 2, 3]
345
+ /// ```
346
+ public let storeBlob : (offset : Nat64, value : Blob) -> () = Prim.stableMemoryStoreBlob;
347
+
348
+ }