Skip to main content

xrpl_common_stdlib/host/
host_bindings_trait.rs

1/// Trait defining all host functions available to WASM smart contracts.
2///
3/// This trait serves as the source of truth for host function signatures and is implemented by:
4/// - `WasmHostBindings`: The production implementation that calls actual host functions via FFI
5/// - `EmptyHostBindings`: Stub implementations for non-WASM builds (panics if called)
6/// - `MockHostBindings`: Generated by `mockall` for unit testing (via `#[automock]`)
7///
8/// # Example
9///
10/// ```rust,ignore
11/// use xrpl_common_stdlib::host::{HostBindings, WasmHostBindings};
12///
13/// fn my_function<H: HostBindings>(host: &H) {
14///     unsafe {
15///         let mut buffer = [0u8; 8];
16///         let result = host.ldgr_index(buffer.as_mut_ptr(), buffer.len());
17///         // ... use result
18///     }
19/// }
20///
21/// // In production code:
22/// let host = WasmHostBindings;
23/// my_function(&host);
24/// ```
25#[allow(unused)] // To remove warn when compiled for non-WASM targets
26#[cfg_attr(
27    all(any(test, feature = "test-host-bindings"), not(target_arch = "wasm32")),
28    mockall::automock
29)]
30pub trait HostBindings {
31    // ###############################
32    // Host Function Category: getters
33    // ###############################
34
35    /// Retrieves the current ledger sequence number.
36    ///
37    /// This function populates a provided buffer with the ledger sequence number.
38    ///
39    /// # Parameters
40    ///
41    /// - `out_buff_ptr`: A mutable pointer to a buffer where the ledger sequence number will be written.
42    /// - `out_buff_len`: The maximum length of the buffer in bytes.
43    ///
44    /// # Returns
45    ///
46    /// - Returns a positive number of bytes written to the output buffer on success
47    /// - Returns a negative error code on failure. The list of error codes is defined in
48    ///   `../core/error_codes.rs`
49    ///
50    /// # Safety
51    /// Caller must ensure all pointer parameters point to valid memory
52    unsafe fn ldgr_index(&self, out_buff_ptr: *mut u8, out_buff_len: usize) -> i32;
53
54    /// Retrieves the parent ledger time.
55    ///
56    /// This function is used to obtain the parent ledger's timestamp as a byte array.
57    /// The timestamp is written into a provided output buffer.
58    ///
59    /// # Parameters
60    ///
61    /// - `out_buff_ptr`: A mutable pointer to a buffer where the parent ledger time will be written.
62    /// - `out_buff_len`: The maximum length of the buffer in bytes.
63    ///
64    /// # Returns
65    ///
66    /// - Returns a positive number of bytes written to the output buffer on success
67    /// - Returns a negative error code on failure. The list of error codes is defined in
68    ///   `../core/error_codes.rs`
69    ///
70    /// # Safety
71    /// Caller must ensure all pointer parameters point to valid memory
72    unsafe fn parent_ldgr_time(&self, out_buff_ptr: *mut u8, out_buff_len: usize) -> i32;
73
74    /// Retrieves the hash of the parent ledger.
75    ///
76    /// This function fetches the hash of the parent ledger and stores it in the buffer provided.
77    /// The hash is expected to be written to the memory location pointed by `out_buff_ptr`,
78    /// and its length should not exceed the `out_buff_len`.
79    ///
80    /// # Parameters
81    /// - `out_buff_ptr`: A mutable pointer to a buffer where the parent ledger hash will be written.
82    ///   The buffer must be allocated and managed by the caller.
83    /// - `out_buff_len`: The maximum length of the buffer in bytes. This indicates the size of the
84    ///   buffer and ensures that the function does not write beyond the allowed length.
85    ///
86    /// # Returns
87    ///
88    /// - Returns a positive number of bytes wrote to an output buffer on success
89    /// - Returns a negative error code on failure. The list of error codes is defined in
90    ///   `../core/error_codes.rs`
91    ///
92    /// # Safety
93    /// Caller must ensure all pointer parameters point to valid memory
94    unsafe fn parent_ldgr_hash(&self, out_buff_ptr: *mut u8, out_buff_len: usize) -> i32;
95
96    /// Retrieves the current transaction base fee.
97    ///
98    /// # Parameters
99    ///
100    /// - `out_buff_ptr`: A mutable pointer to a buffer where the base fee will be written.
101    /// - `out_buff_len`: The maximum length of the buffer in bytes.
102    ///
103    /// # Returns
104    ///
105    /// - Returns a positive number of bytes written to the output buffer on success
106    /// - Returns a negative error code on failure. The list of error codes is defined in
107    ///   ../core/error_codes.rs
108    ///
109    /// # Safety
110    /// Caller must ensure all pointer parameters point to valid memory
111    unsafe fn base_fee(&self, out_buff_ptr: *mut u8, out_buff_len: usize) -> i32;
112
113    /// Retrieves the state of an amendment and whether it's enabled or not.
114    ///
115    /// # Parameters
116    ///
117    /// - `amendment_ptr`: A raw pointer to the amendment. This can be either the uint256 that
118    ///   represents the hash of an amendment, or the string name of the
119    ///   amendment.
120    /// - `amendment_len`: The length of the amendment specified by `amendment_ptr`.
121    ///
122    /// # Returns
123    ///
124    /// - Returns a boolean 0 or 1 (whether the amendment is enabled or not) on success.
125    /// - Returns a negative error code on failure. The list of error codes is defined in
126    ///   ../core/error_codes.rs
127    ///
128    /// # Safety
129    /// Caller must ensure all pointer parameters point to valid memory
130    unsafe fn amendment_enabled(&self, amendment_ptr: *const u8, amendment_len: usize) -> i32;
131
132    /// Fetch a ledger entry pointed by the given ledger entry ID.
133    ///
134    /// This function uses the ledger entry ID to locate a ledger entry. If found, add it to the
135    /// cache. The cache can have up to 255 ledger entries. If `cache_num` is 0, the
136    /// new ledger entry will put in the next available cache space. If `cache_num` is not 0,
137    /// the new ledger entry will replace an existing ledger entry in the catch.
138    ///
139    /// # Parameters
140    ///
141    /// - `id_ptr`: A raw pointer to the ledger entry ID, which is a unique identifier used to
142    ///   locate or store data in the ledger.
143    /// - `id_len`: The length of the ledger entry ID specified by `id_ptr`.
144    /// - `cache_num`: The cache number to which the ledger entry ID will be placed in.
145    ///   If 0, the host will assign a new cache space.
146    ///
147    /// # Returns
148    ///
149    /// - Returns a positive cache number
150    /// - Returns a negative error code on failure
151    ///
152    /// # Safety
153    /// Caller must ensure all pointer parameters point to valid memory
154    unsafe fn cache_le(&self, id_ptr: *const u8, id_len: usize, cache_num: i32) -> i32;
155
156    /// Retrieves a specific transaction field and writes it into the provided output buffer.
157    ///
158    /// # Parameters
159    ///
160    /// * `field` - An integer value representing the specific transaction field to retrieve.
161    /// * `out_buff_ptr` - A mutable pointer to a buffer where the output data will be written.
162    /// * `out_buff_len` - The size (in bytes) of the buffer pointed to by `out_buff_ptr`.
163    ///
164    /// # Returns
165    ///
166    /// - Returns a positive number of bytes wrote to an output buffer on success
167    /// - Returns a negative error code on failure. The list of error codes is defined in
168    ///   `../core/error_codes.rs`
169    ///
170    /// # Safety
171    /// Caller must ensure all pointer parameters point to valid memory
172    unsafe fn tx_field(&self, field: i32, out_buff_ptr: *mut u8, out_buff_len: usize) -> i32;
173
174    /// Retrieves a specific field from the current ledger object and writes it into the provided buffer.
175    ///
176    /// # Parameters
177    /// - `field` (`i32`): The integer identifier for the desired field in the ledger object.
178    /// - `out_buff_ptr` (`*mut u8`): A mutable pointer to the memory location where the field data
179    ///   will be written. This should point to a pre-allocated buffer.
180    /// - `out_buff_len` (`usize`): The size (in bytes) of the buffer provided by `out_buff_ptr`.
181    ///
182    /// # Returns
183    ///
184    /// - Returns a positive number of bytes wrote to an output buffer on success
185    /// - Returns a negative error code on failure. The list of error codes is defined in
186    ///   `../core/error_codes.rs`
187    ///
188    /// # Safety
189    /// Caller must ensure all pointer parameters point to valid memory
190    unsafe fn home_le_field(&self, field: i32, out_buff_ptr: *mut u8, out_buff_len: usize) -> i32;
191
192    /// Retrieves a specific field from a ledger object based on the given parameters.
193    ///
194    /// # Parameters
195    ///
196    /// - `cache_num`: An integer representing the cache index of the ledger object.
197    /// - `field`: An integer representing the specific field to retrieve from the ledger object.
198    /// - `out_buff_ptr`: A mutable pointer to a buffer where the retrieved field data will be written.
199    /// - `out_buff_len`: The size of the output buffer in bytes.
200    ///
201    /// # Returns
202    ///
203    /// - Returns a positive number of bytes wrote to an output buffer on success
204    /// - Returns a negative error code on failure. The list of error codes is defined in
205    ///   `../core/error_codes.rs`
206    ///
207    /// # Safety
208    /// Caller must ensure all pointer parameters point to valid memory
209    unsafe fn le_field(
210        &self,
211        cache_num: i32,
212        field: i32,
213        out_buff_ptr: *mut u8,
214        out_buff_len: usize,
215    ) -> i32;
216
217    /// Retrieves an inner field from the current ledger object and writes it into the provided buffer.
218    ///
219    /// # Parameters
220    /// - `locator_ptr`: A pointer to a byte array containing the locator for the inner field.
221    /// - `locator_len`: The length of the locator data in bytes.
222    /// - `out_buff_ptr`: A pointer to a mutable byte array where the resulting field data will be written.
223    /// - `out_buff_len`: The size of the output buffer in bytes.
224    ///
225    /// # Returns
226    ///
227    /// - Returns a positive number of bytes wrote to an output buffer on success
228    /// - Returns a negative error code on failure. The list of error codes is defined in
229    ///   `../core/error_codes.rs`
230    ///
231    /// # Safety
232    /// Caller must ensure all pointer parameters point to valid memory
233    unsafe fn tx_inner(
234        &self,
235        locator_ptr: *const u8,
236        locator_len: usize,
237        out_buff_ptr: *mut u8,
238        out_buff_len: usize,
239    ) -> i32;
240
241    /// Retrieves a specific inner field from the current ledger object.
242    ///
243    /// This function is designed to access an inner field within the ledger object
244    /// specified by the `locator`. The `locator` acts as a path or identifier to
245    /// the desired field. The resulting data is written to the `out_buff` buffer.
246    /// The function returns a status code indicating success or failure of the operation.
247    ///
248    /// # Parameters
249    /// - `locator_ptr`: A pointer to a byte array containing the locator for the inner field.
250    /// - `locator_len`: The length of the locator data in bytes.
251    /// - `out_buff_ptr`: A pointer to a mutable byte array where the resulting field data will be written.
252    /// - `out_buff_len`: The size of the output buffer in bytes.
253    ///
254    /// # Returns
255    ///
256    /// - Returns a positive number of bytes wrote to an output buffer on success
257    /// - Returns a negative error code on failure. The list of error codes is defined in
258    ///   `../core/error_codes.rs`
259    ///
260    /// # Safety
261    /// Caller must ensure all pointer parameters point to valid memory
262    unsafe fn home_le_inner(
263        &self,
264        locator_ptr: *const u8,
265        locator_len: usize,
266        out_buff_ptr: *mut u8,
267        out_buff_len: usize,
268    ) -> i32;
269
270    /// Retrieves an inner field from a ledger object in a specific cache_num and writes the result into an output buffer.
271    ///
272    /// # Parameters
273    /// - `cache_num`: The cache index of the ledger object to access.
274    /// - `locator_ptr`: A pointer to the memory location containing the locator string data
275    ///   (used to identify the inner field in the ledger object).
276    /// - `locator_len`: The length of the locator string.
277    /// - `out_buff_ptr`: A pointer to the buffer where the retrieved inner field value will be written.
278    /// - `out_buff_len`: The size of the output buffer in bytes.
279    ///
280    /// # Returns
281    ///
282    /// - Returns a positive number of bytes wrote to an output buffer on success
283    /// - Returns a negative error code on failure. The list of error codes is defined in
284    ///   `../core/error_codes.rs`
285    ///
286    /// # Safety
287    /// Caller must ensure all pointer parameters point to valid memory
288    unsafe fn le_inner(
289        &self,
290        cache_num: i32,
291        locator_ptr: *const u8,
292        locator_len: usize,
293        out_buff_ptr: *mut u8,
294        out_buff_len: usize,
295    ) -> i32;
296
297    /// Retrieves the length of an array based on the provided field value.
298    ///
299    /// # Parameters
300    /// - `field` (i32): The integer identifier for the desired field.
301    ///
302    /// # Returns
303    ///
304    /// - Returns a positive number of array length on success
305    /// - Returns a negative error code on failure. The list of error codes is defined in
306    ///   ../core/error_codes.rs
307    ///
308    /// # Safety
309    /// This function is safe to call from WASM context
310    unsafe fn tx_arr_len(&self, field: i32) -> i32;
311
312    /// Retrieves the length of an array based on the provided field value.
313    ///
314    /// # Parameters
315    /// - `field` (i32): The integer identifier for the desired field.
316    ///
317    /// # Returns
318    ///
319    /// - Returns a positive number of array length on success
320    /// - Returns a negative error code on failure. The list of error codes is defined in
321    ///   ../core/error_codes.rs
322    ///
323    /// # Safety
324    /// This function is safe to call from WASM context
325    unsafe fn home_le_arr_len(&self, field: i32) -> i32;
326
327    /// Retrieves the length of an array based on the provided cache number and field value.
328    ///
329    /// # Parameters
330    /// - `cache_num`: The cache index of the ledger object to access.
331    /// - `field` (i32): The integer identifier for the desired field.
332    ///
333    /// # Returns
334    ///
335    /// - Returns a positive number of array length on success
336    /// - Returns a negative error code on failure. The list of error codes is defined in
337    ///   ../core/error_codes.rs
338    ///
339    /// # Safety
340    /// This function is safe to call from WASM context
341    unsafe fn le_arr_len(&self, cache_num: i32, field: i32) -> i32;
342
343    /// Retrieves the length of an array based on the provided locator.
344    ///
345    /// # Parameters
346    /// - `locator_ptr`: A pointer to a byte array containing the locator for the inner field.
347    /// - `locator_len`: The length of the locator data in bytes.
348    ///
349    /// # Returns
350    ///
351    /// - Returns a positive number of array length on success
352    /// - Returns a negative error code on failure. The list of error codes is defined in
353    ///   ../core/error_codes.rs
354    ///
355    /// # Safety
356    /// Caller must ensure all pointer parameters point to valid memory
357    unsafe fn tx_inner_arr_len(&self, locator_ptr: *const u8, locator_len: usize) -> i32;
358
359    /// Retrieves the length of an array based on the provided locator.
360    ///
361    /// # Parameters
362    /// - `locator_ptr`: A pointer to a byte array containing the locator for the inner field.
363    /// - `locator_len`: The length of the locator data in bytes.
364    ///
365    /// # Returns
366    ///
367    /// - Returns a positive number of array length on success
368    /// - Returns a negative error code on failure. The list of error codes is defined in
369    ///   ../core/error_codes.rs
370    ///
371    /// # Safety
372    /// Caller must ensure all pointer parameters point to valid memory
373    unsafe fn home_le_inner_arr_len(&self, locator_ptr: *const u8, locator_len: usize) -> i32;
374
375    /// Retrieves the length of an array based on the provided locator.
376    ///
377    /// # Parameters
378    /// - `cache_num`: The cache index of the ledger object to access.
379    /// - `locator_ptr`: A pointer to a byte array containing the locator for the inner field.
380    /// - `locator_len`: The length of the locator data in bytes.
381    ///
382    /// # Returns
383    ///
384    /// - Returns a positive number of array length on success
385    /// - Returns a negative error code on failure. The list of error codes is defined in
386    ///   ../core/error_codes.rs
387    ///
388    /// # Safety
389    /// Caller must ensure all pointer parameters point to valid memory
390    unsafe fn le_inner_arr_len(
391        &self,
392        cache_num: i32,
393        locator_ptr: *const u8,
394        locator_len: usize,
395    ) -> i32;
396
397    // ###################################################
398    // Host Function Category: update current ledger entry
399    // ###################################################
400
401    /// Updates a data field of the current ledger entry
402    ///
403    /// # Parameters
404    ///
405    /// - `data_ptr`: A pointer to the data to be written.
406    /// - `data_len`: The size of the data.
407    ///
408    /// # Returns
409    ///
410    /// - 0 on success
411    /// - negative for an error
412    ///
413    /// # Safety
414    /// Caller must ensure all pointer parameters point to valid memory
415    unsafe fn set_data(&self, data_ptr: *const u8, data_len: usize) -> i32;
416
417    // ###################################################
418    // Host Function Category: hash and ledger entry ID computation
419    // ###################################################
420
421    /// Computes the first 32 bytes (half) of the SHA-512 hash for the given input data.
422    ///
423    /// # Parameters
424    ///
425    /// - `data_ptr`: A pointer to the input data to be hashed.
426    /// - `data_len`: The length, in bytes, of the input data.
427    /// - `out_buff_ptr`: A pointer to the buffer where the resulting 32-byte hash will be written.
428    /// - `out_buff_len`: The length, in bytes, of the output buffer.
429    ///
430    /// # Returns
431    ///
432    /// - Returns a positive number of bytes wrote to an output buffer on success
433    /// - Returns a negative error code on failure. The list of error codes is defined in
434    ///   ../core/error_codes.rs
435    ///
436    /// # Safety
437    /// Caller must ensure all pointer parameters point to valid memory
438    unsafe fn sha512_half(
439        &self,
440        data_ptr: *const u8,
441        data_len: usize,
442        out_buff_ptr: *mut u8,
443        out_buff_len: usize,
444    ) -> i32;
445
446    /// Checks a key signature when provided the message and public key.
447    ///
448    /// # Parameters
449    /// - `message_ptr`: A pointer to the message data to be verified.
450    /// - `message_len`: The length, in bytes, of the message data.
451    /// - `signature_ptr`: A pointer to the signature data.
452    /// - `signature_len`: The length, in bytes, of the signature data.
453    /// - `pubkey_ptr`: A pointer to the public key data.
454    /// - `pubkey_len`: The length, in bytes, of the public key data.
455    ///
456    /// # Returns
457    ///
458    /// - Returns 1 if the signature is valid.
459    /// - Returns 0 if the signature is invalid.
460    /// - Returns a negative error code on failure. The list of error codes is defined in
461    ///   ../core/error_codes.rs
462    ///
463    /// # Safety
464    /// Caller must ensure all pointer parameters point to valid memory
465    unsafe fn check_sig(
466        &self,
467        message_ptr: *const u8,
468        message_len: usize,
469        signature_ptr: *const u8,
470        signature_len: usize,
471        pubkey_ptr: *const u8,
472        pubkey_len: usize,
473    ) -> i32;
474
475    /// Generates the ledger entry ID (key identifier) for a specific account.
476    ///
477    /// This function is used to calculate the account ledger entry ID in a cryptographic or
478    /// blockchain-based system. A ledger entry ID is typically used to identify an account or entity
479    /// in a secure and deterministic way.
480    ///
481    /// # Parameters
482    ///
483    /// - `account_ptr`: A pointer to the memory of the account identifier.
484    /// - `account_len`: The size (in bytes) of the data pointed to by `account_ptr`.
485    /// - `out_buff_ptr`: A pointer to the memory where the generated ledger entry ID will be stored.
486    /// - `out_buff_len`: The length (in bytes) of the buffer pointed to by `out_buff_ptr`.
487    ///
488    /// # Returns
489    ///
490    /// - Returns a positive number of bytes wrote to an output buffer on success
491    /// - Returns a negative error code on failure. The list of error codes is defined in
492    ///   `../core/error_codes.rs`
493    ///
494    /// # Safety
495    /// Caller must ensure all pointer parameters point to valid memory
496    unsafe fn accountroot_id(
497        &self,
498        account_ptr: *const u8,
499        account_len: usize,
500        out_buff_ptr: *mut u8,
501        out_buff_len: usize,
502    ) -> i32;
503
504    /// Generates the ledger entry ID (key identifier) for a specific AMM.
505    ///
506    /// This function is used to calculate the AMM ledger entry ID in a cryptographic or
507    /// blockchain-based system. A ledger entry ID is typically used to identify an AMM or entity
508    /// in a secure and deterministic way.
509    ///
510    /// # Parameters
511    ///
512    /// - `issue1_ptr`: A pointer to the memory of the issue1 identifier.
513    /// - `issue1_len`: The size (in bytes) of the data pointed to by `issue1_ptr`.
514    /// - `issue2_ptr`: A pointer to the memory of the issue2 identifier.
515    /// - `issue2_len`: The size (in bytes) of the data pointed to by `issue2_ptr`.
516    /// - `out_buff_ptr`: A pointer to the memory where the generated ledger entry ID will be stored.
517    /// - `out_buff_len`: The length (in bytes) of the buffer pointed to by `out_buff_ptr`.
518    ///
519    /// # Returns
520    ///
521    /// - Returns a positive number of bytes wrote to an output buffer on success
522    /// - Returns a negative error code on failure. The list of error codes is defined in
523    ///   `../core/error_codes.rs`
524    ///
525    /// # Safety
526    /// Caller must ensure all pointer parameters point to valid memory
527    unsafe fn amm_id(
528        &self,
529        issue1_ptr: *const u8,
530        issue1_len: usize,
531        issue2_ptr: *const u8,
532        issue2_len: usize,
533        out_buff_ptr: *mut u8,
534        out_buff_len: usize,
535    ) -> i32;
536
537    /// Computes the Ledger entry ID for a check entry in a ledger.
538    ///
539    /// # Parameters
540    ///
541    /// - `account_ptr`: A pointer to the memory location of the accountID.
542    /// - `account_len`: The length of the accountID.
543    /// - `sequence_ptr`: A pointer to the memory location of the account sequence number.
544    /// - `sequence_len`: The length of the sequence data.
545    /// - `out_buff_ptr`: A pointer to the output buffer where the derived ledger entry ID will be stored.
546    /// - `out_buff_len`: The length of the output buffer.
547    ///
548    /// # Returns
549    ///
550    /// - Returns a positive number of bytes wrote to an output buffer on success
551    /// - Returns a negative error code on failure. The list of error codes is defined in
552    ///   ../core/error_codes.rs
553    ///
554    /// # Safety
555    /// Caller must ensure all pointer parameters point to valid memory
556    unsafe fn check_id(
557        &self,
558        account_ptr: *const u8,
559        account_len: usize,
560        sequence_ptr: *const u8,
561        sequence_len: usize,
562        out_buff_ptr: *mut u8,
563        out_buff_len: usize,
564    ) -> i32;
565
566    /// Generates a ledger entry ID for a credential.
567    ///
568    /// # Parameters
569    ///
570    /// * `subject_ptr`: A pointer to the memory location where the subject data begins.
571    /// * `subject_len`: The length of the subject data in bytes.
572    /// * `issuer_ptr`: A pointer to the memory location where the issuer data begins.
573    /// * `issuer_len`: The length of the issuer data in bytes.
574    /// * `cred_type_ptr`: A pointer to the memory location where the credential type data begins.
575    /// * `cred_type_len`: The length of the credential type data in bytes.
576    /// * `out_buff_ptr`: A pointer to the buffer where the generated ledger entry ID will be written.
577    /// * `out_buff_len`: The size of the output buffer in bytes.
578    ///
579    /// # Returns
580    ///
581    /// - Returns a positive number of bytes wrote to an output buffer on success
582    /// - Returns a negative error code on failure. The list of error codes is defined in
583    ///   `../core/error_codes.rs`
584    ///
585    /// # Safety
586    /// Caller must ensure all pointer parameters point to valid memory
587    #[allow(clippy::too_many_arguments)]
588    unsafe fn credential_id(
589        &self,
590        subject_ptr: *const u8,
591        subject_len: usize,
592        issuer_ptr: *const u8,
593        issuer_len: usize,
594        cred_type_ptr: *const u8,
595        cred_type_len: usize,
596        out_buff_ptr: *mut u8,
597        out_buff_len: usize,
598    ) -> i32;
599
600    /// Computes the Ledger entry ID for a delegate entry in a ledger.
601    ///
602    /// # Parameters
603    ///
604    /// - `account_ptr`: A pointer to the memory location of the accountID.
605    /// - `account_len`: The length of the accountID.
606    /// - `authorize_ptr`: A pointer to the memory location of the authorized account.
607    /// - `authorize_len`: The length of the authorized account.
608    /// - `out_buff_ptr`: A pointer to the output buffer where the derived ledger entry ID will be stored.
609    /// - `out_buff_len`: The length of the output buffer.
610    ///
611    /// # Returns
612    ///
613    /// - Returns a positive number of bytes wrote to an output buffer on success
614    /// - Returns a negative error code on failure. The list of error codes is defined in
615    ///   ../core/error_codes.rs
616    ///
617    /// # Safety
618    /// Caller must ensure all pointer parameters point to valid memory
619    unsafe fn delegate_id(
620        &self,
621        account_ptr: *const u8,
622        account_len: usize,
623        authorize_ptr: *const u8,
624        authorize_len: usize,
625        out_buff_ptr: *mut u8,
626        out_buff_len: usize,
627    ) -> i32;
628
629    /// Computes the Ledger entry ID for a deposit preauth entry in a ledger.
630    ///
631    /// # Parameters
632    ///
633    /// - `account_ptr`: A pointer to the memory location of the accountID.
634    /// - `account_len`: The length of the accountID.
635    /// - `authorize_ptr`: A pointer to the memory location of the authorized account.
636    /// - `authorize_len`: The length of the authorized account.
637    /// - `out_buff_ptr`: A pointer to the output buffer where the derived ledger entry ID will be stored.
638    /// - `out_buff_len`: The length of the output buffer.
639    ///
640    /// # Returns
641    ///
642    /// - Returns a positive number of bytes wrote to an output buffer on success
643    /// - Returns a negative error code on failure. The list of error codes is defined in
644    ///   ../core/error_codes.rs
645    ///
646    /// # Safety
647    /// Caller must ensure all pointer parameters point to valid memory
648    unsafe fn deposit_preauth_id(
649        &self,
650        account_ptr: *const u8,
651        account_len: usize,
652        authorize_ptr: *const u8,
653        authorize_len: usize,
654        out_buff_ptr: *mut u8,
655        out_buff_len: usize,
656    ) -> i32;
657
658    /// Computes the Ledger entry ID for a DID entry in a ledger.
659    ///
660    /// # Parameters
661    ///
662    /// - `account_ptr`: A pointer to the memory location of the accountID.
663    /// - `account_len`: The length of the accountID.
664    /// - `out_buff_ptr`: A pointer to the output buffer where the derived ledger entry ID will be stored.
665    /// - `out_buff_len`: The length of the output buffer.
666    ///
667    /// # Returns
668    ///
669    /// - Returns a positive number of bytes wrote to an output buffer on success
670    /// - Returns a negative error code on failure. The list of error codes is defined in
671    ///   ../core/error_codes.rs
672    ///
673    /// # Safety
674    /// Caller must ensure all pointer parameters point to valid memory
675    unsafe fn did_id(
676        &self,
677        account_ptr: *const u8,
678        account_len: usize,
679        out_buff_ptr: *mut u8,
680        out_buff_len: usize,
681    ) -> i32;
682
683    /// Computes the Ledger entry ID for an escrow entry in a ledger.
684    ///
685    /// # Parameters
686    ///
687    /// - `account_ptr`: A pointer to the memory location of the accountID.
688    /// - `account_len`: The length of the accountID.
689    /// - `sequence_ptr`: A pointer to the memory location of the account sequence number.
690    /// - `sequence_len`: The length of the sequence data.
691    /// - `out_buff_ptr`: A pointer to the output buffer where the derived ledger entry ID will be stored.
692    /// - `out_buff_len`: The length of the output buffer.
693    ///
694    /// # Returns
695    ///
696    /// - Returns a positive number of bytes wrote to an output buffer on success
697    /// - Returns a negative error code on failure. The list of error codes is defined in
698    ///   `../core/error_codes.rs`
699    ///
700    /// # Safety
701    /// Caller must ensure all pointer parameters point to valid memory
702    unsafe fn escrow_id(
703        &self,
704        account_ptr: *const u8,
705        account_len: usize,
706        sequence_ptr: *const u8,
707        sequence_len: usize,
708        out_buff_ptr: *mut u8,
709        out_buff_len: usize,
710    ) -> i32;
711
712    /// Computes the Ledger entry ID for a trustline entry in a ledger.
713    ///
714    /// # Parameters
715    ///
716    /// - `account1_ptr`: A pointer to the memory location of the first accountID.
717    /// - `account1_len`: The length of the first accountID.
718    /// - `account2_ptr`: A pointer to the memory location of the second accountID.
719    /// - `account2_len`: The length of the second accountID.
720    /// - `currency_ptr`: A pointer to the memory location of the currency.
721    /// - `currency_len`: The length of the currency.
722    /// - `out_buff_ptr`: A pointer to the output buffer where the derived ledger entry ID will be stored.
723    /// - `out_buff_len`: The length of the output buffer.
724    ///
725    /// # Returns
726    ///
727    /// - Returns a positive number of bytes wrote to an output buffer on success
728    /// - Returns a negative error code on failure. The list of error codes is defined in
729    ///   ../core/error_codes.rs
730    ///
731    /// # Safety
732    /// Caller must ensure all pointer parameters point to valid memory
733    #[allow(clippy::too_many_arguments)]
734    unsafe fn trustline_id(
735        &self,
736        account1_ptr: *const u8,
737        account1_len: usize,
738        account2_ptr: *const u8,
739        account2_len: usize,
740        currency_ptr: *const u8,
741        currency_len: usize,
742        out_buff_ptr: *mut u8,
743        out_buff_len: usize,
744    ) -> i32;
745
746    /// Computes the Ledger entry ID for an MPT issuance entry in a ledger.
747    ///
748    /// # Parameters
749    ///
750    /// - `issuer_ptr`: A pointer to the memory location of the accountID.
751    /// - `issuer_len`: The length of the accountID.
752    /// - `sequence_ptr`: A pointer to the memory location of the account sequence number.
753    /// - `sequence_len`: The length of the sequence data.
754    /// - `out_buff_ptr`: A pointer to the output buffer where the derived ledger entry ID will be stored.
755    /// - `out_buff_len`: The length of the output buffer.
756    ///
757    /// # Returns
758    ///
759    /// - Returns a positive number of bytes wrote to an output buffer on success
760    /// - Returns a negative error code on failure. The list of error codes is defined in
761    ///   `../core/error_codes.rs`
762    ///
763    /// # Safety
764    /// Caller must ensure all pointer parameters point to valid memory
765    unsafe fn mpt_issuance_id(
766        &self,
767        issuer_ptr: *const u8,
768        issuer_len: usize,
769        sequence_ptr: *const u8,
770        sequence_len: usize,
771        out_buff_ptr: *mut u8,
772        out_buff_len: usize,
773    ) -> i32;
774
775    /// Computes the Ledger entry ID for an MPToken entry in a ledger.
776    ///
777    /// # Parameters
778    ///
779    /// - `mptid_ptr`: A pointer to the memory location of the MPTID.
780    /// - `mptid_len`: The length of the MPTID.
781    /// - `holder_ptr`: A pointer to the memory location of the holder account.
782    /// - `holder_len`: The length of the holder account.
783    /// - `out_buff_ptr`: A pointer to the output buffer where the derived ledger entry ID will be stored.
784    /// - `out_buff_len`: The length of the output buffer.
785    ///
786    /// # Returns
787    ///
788    /// - Returns a positive number of bytes wrote to an output buffer on success
789    /// - Returns a negative error code on failure. The list of error codes is defined in
790    ///   ../core/error_codes.rs
791    ///
792    /// # Safety
793    /// Caller must ensure all pointer parameters point to valid memory
794    unsafe fn mptoken_id(
795        &self,
796        mptid_ptr: *const u8,
797        mptid_len: usize,
798        holder_ptr: *const u8,
799        holder_len: usize,
800        out_buff_ptr: *mut u8,
801        out_buff_len: usize,
802    ) -> i32;
803
804    /// Computes the Ledger entry ID for an NFT offer entry in a ledger.
805    ///
806    /// # Parameters
807    ///
808    /// - `account_ptr`: A pointer to the memory location of the accountID.
809    /// - `account_len`: The length of the accountID.
810    /// - `sequence_ptr`: A pointer to the memory location of the account sequence number.
811    /// - `sequence_len`: The length of the sequence data.
812    /// - `out_buff_ptr`: A pointer to the output buffer where the derived ledger entry ID will be stored.
813    /// - `out_buff_len`: The length of the output buffer.
814    ///
815    /// # Returns
816    ///
817    /// - Returns a positive number of bytes wrote to an output buffer on success
818    /// - Returns a negative error code on failure. The list of error codes is defined in
819    ///   ../core/error_codes.rs
820    ///
821    /// # Safety
822    /// Caller must ensure all pointer parameters point to valid memory
823    unsafe fn nft_offer_id(
824        &self,
825        account_ptr: *const u8,
826        account_len: usize,
827        sequence_ptr: *const u8,
828        sequence_len: usize,
829        out_buff_ptr: *mut u8,
830        out_buff_len: usize,
831    ) -> i32;
832
833    /// Computes the Ledger entry ID for an offer entry in a ledger.
834    ///
835    /// # Parameters
836    ///
837    /// - `account_ptr`: A pointer to the memory location of the accountID.
838    /// - `account_len`: The length of the accountID.
839    /// - `sequence_ptr`: A pointer to the memory location of the account sequence number.
840    /// - `sequence_len`: The length of the sequence data.
841    /// - `out_buff_ptr`: A pointer to the output buffer where the derived ledger entry ID will be stored.
842    /// - `out_buff_len`: The length of the output buffer.
843    ///
844    /// # Returns
845    ///
846    /// - Returns a positive number of bytes wrote to an output buffer on success
847    /// - Returns a negative error code on failure. The list of error codes is defined in
848    ///   ../core/error_codes.rs
849    ///
850    /// # Safety
851    /// Caller must ensure all pointer parameters point to valid memory
852    unsafe fn offer_id(
853        &self,
854        account_ptr: *const u8,
855        account_len: usize,
856        sequence_ptr: *const u8,
857        sequence_len: usize,
858        out_buff_ptr: *mut u8,
859        out_buff_len: usize,
860    ) -> i32;
861
862    /// Generates a ledger entry ID associated with an oracle's account and document ID.
863    ///
864    /// # Parameters
865    ///
866    /// - `account_ptr`: A pointer to the memory location of the accountID.
867    /// - `account_len`: The length of the accountID.
868    /// - `document_id_ptr`: A pointer to the memory location of the document ID.
869    /// - `document_id_len`: The length of the document ID data.
870    /// - `out_buff_ptr`: A pointer to a pre-allocated buffer where the resulting ledger entry ID will be
871    ///   written.
872    /// - `out_buff_len`: The size of the output buffer in bytes.
873    ///
874    /// # Returns
875    ///
876    /// - Returns a positive number of bytes wrote to an output buffer on success
877    /// - Returns a negative error code on failure. The list of error codes is defined in
878    ///   `../core/error_codes.rs`
879    ///
880    /// # Safety
881    /// Caller must ensure all pointer parameters point to valid memory
882    unsafe fn oracle_id(
883        &self,
884        account_ptr: *const u8,
885        account_len: usize,
886        document_id_ptr: *const u8,
887        document_id_len: usize,
888        out_buff_ptr: *mut u8,
889        out_buff_len: usize,
890    ) -> i32;
891
892    /// Computes the Ledger entry ID for a payment channel entry in a ledger.
893    ///
894    /// # Parameters
895    ///
896    /// - `account_ptr`: A pointer to the memory location of the accountID.
897    /// - `account_len`: The length of the accountID.
898    /// - `destination_ptr`: A pointer to the memory location of the destination.
899    /// - `destination_len`: The length of the destination.
900    /// - `sequence_ptr`: A pointer to the memory location of the account sequence number.
901    /// - `sequence_len`: The length of the sequence data.
902    /// - `out_buff_ptr`: A pointer to the output buffer where the derived ledger entry ID will be stored.
903    /// - `out_buff_len`: The length of the output buffer.
904    ///
905    /// # Returns
906    ///
907    /// - Returns a positive number of bytes wrote to an output buffer on success
908    /// - Returns a negative error code on failure. The list of error codes is defined in
909    ///   ../core/error_codes.rs
910    ///
911    /// # Safety
912    /// Caller must ensure all pointer parameters point to valid memory
913    #[allow(clippy::too_many_arguments)]
914    unsafe fn paychan_id(
915        &self,
916        account_ptr: *const u8,
917        account_len: usize,
918        destination_ptr: *const u8,
919        destination_len: usize,
920        sequence_ptr: *const u8,
921        sequence_len: usize,
922        out_buff_ptr: *mut u8,
923        out_buff_len: usize,
924    ) -> i32;
925
926    /// Computes the Ledger entry ID for a permissioned domain entry in a ledger.
927    ///
928    /// # Parameters
929    ///
930    /// - `account_ptr`: A pointer to the memory location of the accountID.
931    /// - `account_len`: The length of the accountID.
932    /// - `sequence_ptr`: A pointer to the memory location of the account sequence number.
933    /// - `sequence_len`: The length of the sequence data.
934    /// - `out_buff_ptr`: A pointer to the output buffer where the derived ledger entry ID will be stored.
935    /// - `out_buff_len`: The length of the output buffer.
936    ///
937    /// # Returns
938    ///
939    /// - Returns a positive number of bytes wrote to an output buffer on success
940    /// - Returns a negative error code on failure. The list of error codes is defined in
941    ///   ../core/error_codes.rs
942    ///
943    /// # Safety
944    /// Caller must ensure all pointer parameters point to valid memory
945    unsafe fn permissioned_domain_id(
946        &self,
947        account_ptr: *const u8,
948        account_len: usize,
949        sequence_ptr: *const u8,
950        sequence_len: usize,
951        out_buff_ptr: *mut u8,
952        out_buff_len: usize,
953    ) -> i32;
954
955    /// Computes the Ledger entry ID for a signer entry in a ledger.
956    ///
957    /// # Parameters
958    ///
959    /// - `account_ptr`: A pointer to the memory location of the accountID.
960    /// - `account_len`: The length of the accountID.
961    /// - `out_buff_ptr`: A pointer to the output buffer where the derived ledger entry ID will be stored.
962    /// - `out_buff_len`: The length of the output buffer.
963    ///
964    /// # Returns
965    ///
966    /// - Returns a positive number of bytes wrote to an output buffer on success
967    /// - Returns a negative error code on failure. The list of error codes is defined in
968    ///   ../core/error_codes.rs
969    ///
970    /// # Safety
971    /// Caller must ensure all pointer parameters point to valid memory
972    unsafe fn signers_id(
973        &self,
974        account_ptr: *const u8,
975        account_len: usize,
976        out_buff_ptr: *mut u8,
977        out_buff_len: usize,
978    ) -> i32;
979
980    /// Computes the Ledger entry ID for a ticket entry in a ledger.
981    ///
982    /// # Parameters
983    ///
984    /// - `account_ptr`: A pointer to the memory location of the accountID.
985    /// - `account_len`: The length of the accountID.
986    /// - `sequence_ptr`: A pointer to the memory location of the account sequence number.
987    /// - `sequence_len`: The length of the sequence data.
988    /// - `out_buff_ptr`: A pointer to the output buffer where the derived ledger entry ID will be stored.
989    /// - `out_buff_len`: The length of the output buffer.
990    ///
991    /// # Returns
992    ///
993    /// - Returns a positive number of bytes wrote to an output buffer on success
994    /// - Returns a negative error code on failure. The list of error codes is defined in
995    ///   ../core/error_codes.rs
996    ///
997    /// # Safety
998    /// Caller must ensure all pointer parameters point to valid memory
999    unsafe fn ticket_id(
1000        &self,
1001        account_ptr: *const u8,
1002        account_len: usize,
1003        sequence_ptr: *const u8,
1004        sequence_len: usize,
1005        out_buff_ptr: *mut u8,
1006        out_buff_len: usize,
1007    ) -> i32;
1008
1009    /// Computes the Ledger entry ID for a vault entry in a ledger.
1010    ///
1011    /// # Parameters
1012    ///
1013    /// - `account_ptr`: A pointer to the memory location of the accountID.
1014    /// - `account_len`: The length of the accountID.
1015    /// - `sequence_ptr`: A pointer to the memory location of the account sequence number.
1016    /// - `sequence_len`: The length of the sequence data.
1017    /// - `out_buff_ptr`: A pointer to the output buffer where the derived ledger entry ID will be stored.
1018    /// - `out_buff_len`: The length of the output buffer.
1019    ///
1020    /// # Returns
1021    ///
1022    /// - Returns a positive number of bytes wrote to an output buffer on success
1023    /// - Returns a negative error code on failure. The list of error codes is defined in
1024    ///   ../core/error_codes.rs
1025    ///
1026    /// # Safety
1027    /// Caller must ensure all pointer parameters point to valid memory
1028    unsafe fn vault_id(
1029        &self,
1030        account_ptr: *const u8,
1031        account_len: usize,
1032        sequence_ptr: *const u8,
1033        sequence_len: usize,
1034        out_buff_ptr: *mut u8,
1035        out_buff_len: usize,
1036    ) -> i32;
1037
1038    // #############################
1039    // Host Function Category: NFT
1040    // #############################
1041
1042    /// Retrieves the URI details of a specific NFT (Non-Fungible Token) associated with a given account.
1043    ///
1044    /// # Parameters
1045    ///
1046    /// - `account_ptr`: A pointer to the memory location of the accountID.
1047    /// - `account_len`: The length of the accountID.
1048    /// - `nft_id_ptr`: A pointer to the memory location containing the NFT identifier.
1049    /// - `nft_id_len`: The length of the NFT identifier in bytes.
1050    /// - `out_buff_ptr`: A mutable pointer to the memory location where the retrieved NFT URI
1051    ///   will be written.
1052    /// - `out_buff_len`: The maximum length of the output buffer.
1053    ///
1054    /// # Returns
1055    ///
1056    /// - Returns a positive number of bytes wrote to an output buffer on success
1057    /// - Returns a negative error code on failure. The list of error codes is defined in
1058    ///   `../core/error_codes.rs`
1059    ///
1060    /// # Safety
1061    /// Caller must ensure all pointer parameters point to valid memory
1062    unsafe fn nft_uri(
1063        &self,
1064        account_ptr: *const u8,
1065        account_len: usize,
1066        nft_id_ptr: *const u8,
1067        nft_id_len: usize,
1068        out_buff_ptr: *mut u8,
1069        out_buff_len: usize,
1070    ) -> i32;
1071
1072    /// Retrieves the issuer of a specific NFT (Non-Fungible Token).
1073    ///
1074    /// # Parameters
1075    ///
1076    /// - `nft_id_ptr`: A pointer to the memory location containing the NFT identifier.
1077    /// - `nft_id_len`: The length of the NFT identifier in bytes.
1078    /// - `out_buff_ptr`: A mutable pointer to the memory location where the retrieved issuer
1079    ///   account will be written.
1080    /// - `out_buff_len`: The maximum length of the output buffer.
1081    ///
1082    /// # Returns
1083    ///
1084    /// - Returns a positive number of bytes wrote to an output buffer on success
1085    /// - Returns a negative error code on failure. The list of error codes is defined in
1086    ///   ../core/error_codes.rs
1087    ///
1088    /// # Safety
1089    /// Caller must ensure all pointer parameters point to valid memory
1090    unsafe fn nft_issuer(
1091        &self,
1092        nft_id_ptr: *const u8,
1093        nft_id_len: usize,
1094        out_buff_ptr: *mut u8,
1095        out_buff_len: usize,
1096    ) -> i32;
1097
1098    /// Retrieves the taxon of a specific NFT (Non-Fungible Token).
1099    ///
1100    /// # Parameters
1101    ///
1102    /// - `nft_id_ptr`: A pointer to the memory location containing the NFT identifier.
1103    /// - `nft_id_len`: The length of the NFT identifier in bytes.
1104    /// - `out_buff_ptr`: A mutable pointer to the memory location where the retrieved taxon
1105    ///   will be written.
1106    /// - `out_buff_len`: The maximum length of the output buffer.
1107    ///
1108    /// # Returns
1109    ///
1110    /// - Returns a positive number of bytes wrote to an output buffer on success
1111    /// - Returns a negative error code on failure. The list of error codes is defined in
1112    ///   ../core/error_codes.rs
1113    ///
1114    /// # Safety
1115    /// Caller must ensure all pointer parameters point to valid memory
1116    unsafe fn nft_taxon(
1117        &self,
1118        nft_id_ptr: *const u8,
1119        nft_id_len: usize,
1120        out_buff_ptr: *mut u8,
1121        out_buff_len: usize,
1122    ) -> i32;
1123
1124    /// Retrieves the flags of a specific NFT (Non-Fungible Token).
1125    ///
1126    /// # Parameters
1127    ///
1128    /// - `nft_id_ptr`: A pointer to the memory location containing the NFT identifier.
1129    /// - `nft_id_len`: The length of the NFT identifier in bytes.
1130    ///
1131    /// # Returns
1132    ///
1133    /// - Returns a positive flags value on success, which is a bitmask representing the NFT's flags
1134    /// - Returns a negative error code on failure. The list of error codes is defined in
1135    ///   ../core/error_codes.rs
1136    ///
1137    /// # Safety
1138    /// Caller must ensure all pointer parameters point to valid memory
1139    unsafe fn nft_flags(&self, nft_id_ptr: *const u8, nft_id_len: usize) -> i32;
1140
1141    /// Retrieves the transfer fee of a specific NFT (Non-Fungible Token).
1142    ///
1143    /// # Parameters
1144    ///
1145    /// - `nft_id_ptr`: A pointer to the memory location containing the NFT identifier.
1146    /// - `nft_id_len`: The length of the NFT identifier in bytes.
1147    ///
1148    /// # Returns
1149    ///
1150    /// - Returns a positive transfer fee value on success
1151    /// - Returns a negative error code on failure. The list of error codes is defined in
1152    ///   ../core/error_codes.rs
1153    ///
1154    /// # Safety
1155    /// Caller must ensure all pointer parameters point to valid memory
1156    unsafe fn nft_xfer_fee(&self, nft_id_ptr: *const u8, nft_id_len: usize) -> i32;
1157
1158    /// Retrieves the serial number of a specific NFT (Non-Fungible Token).
1159    ///
1160    /// # Parameters
1161    ///
1162    /// - `nft_id_ptr`: A pointer to the memory location containing the NFT identifier.
1163    /// - `nft_id_len`: The length of the NFT identifier in bytes.
1164    /// - `out_buff_ptr`: A mutable pointer to the memory location where the retrieved serial
1165    ///   number will be written.
1166    /// - `out_buff_len`: The maximum length of the output buffer.
1167    ///
1168    /// # Returns
1169    ///
1170    /// - Returns a positive number of bytes wrote to an output buffer on success
1171    /// - Returns a negative error code on failure. The list of error codes is defined in
1172    ///   ../core/error_codes.rs
1173    ///
1174    /// # Safety
1175    /// Caller must ensure all pointer parameters point to valid memory
1176    unsafe fn nft_serial(
1177        &self,
1178        nft_id_ptr: *const u8,
1179        nft_id_len: usize,
1180        out_buff_ptr: *mut u8,
1181        out_buff_len: usize,
1182    ) -> i32;
1183
1184    // #############################
1185    // Host Function Category: FLOAT
1186    // #############################
1187
1188    /// Converts a signed 64-bit integer to an opaque float representation
1189    /// # Parameters
1190    /// * `in_int` - The input integer to convert
1191    /// * `out_buff` - Pointer to output buffer where the float will be written
1192    /// * `out_buff_len` - The length of the output buffer in bytes
1193    /// * `rounding_mode` - Rounding mode to use for the conversion
1194    /// # Returns
1195    /// 8 on success, error code otherwise
1196    ///
1197    /// # Safety
1198    /// Caller must ensure all pointer parameters point to valid memory
1199    unsafe fn float_from_int(
1200        &self,
1201        in_int: i64,
1202        out_buff: *mut u8,
1203        out_buff_len: usize,
1204        rounding_mode: i32,
1205    ) -> i32;
1206
1207    /// Converts an unsigned integer to an opaque float representation
1208    /// # Parameters
1209    /// * `in_uint_ptr` - Pointer to the input unsigned integer
1210    /// * `in_uint_len` - The length of the input unsigned integer in bytes
1211    /// * `out_buff` - Pointer to output buffer where the float will be written
1212    /// * `out_buff_len` - The length of the output buffer in bytes
1213    /// * `rounding_mode` - Rounding mode to use for the conversion
1214    /// # Returns
1215    /// 8 on success, error code otherwise
1216    ///
1217    /// # Safety
1218    /// Caller must ensure all pointer parameters point to valid memory
1219    unsafe fn float_from_uint(
1220        &self,
1221        in_uint_ptr: *const u8,
1222        in_uint_len: usize,
1223        out_buff: *mut u8,
1224        out_buff_len: usize,
1225        rounding_mode: i32,
1226    ) -> i32;
1227
1228    /// Creates a float from explicit mantissa and exponent values
1229    /// # Parameters
1230    /// * `mantissa` - The mantissa value
1231    /// * `exponent` - The exponent value
1232    /// * `out_buff` - Pointer to output buffer where the float will be written
1233    /// * `out_buff_len` - The length of the output buffer in bytes
1234    /// * `rounding_mode` - Rounding mode to use for the operation
1235    /// # Returns
1236    /// 8 on success, error code otherwise
1237    ///
1238    /// # Safety
1239    /// Caller must ensure all pointer parameters point to valid memory
1240    unsafe fn float_from_mant_exp(
1241        &self,
1242        mantissa: i64,
1243        exponent: i32,
1244        out_buff: *mut u8,
1245        out_buff_len: usize,
1246        rounding_mode: i32,
1247    ) -> i32;
1248
1249    /// Creates a float from an STAmount serialized value
1250    /// # Parameters
1251    /// * `in_buff` - Pointer to input STAmount buffer
1252    /// * `in_buff_len` - The length of the input buffer in bytes
1253    /// * `out_buff` - Pointer to output buffer where the float will be written
1254    /// * `out_buff_len` - The length of the output buffer in bytes
1255    /// * `rounding_mode` - Rounding mode to use for the operation
1256    /// # Returns
1257    /// 8 on success, error code otherwise
1258    ///
1259    /// # Safety
1260    /// Caller must ensure all pointer parameters point to valid memory
1261    unsafe fn float_from_stamount(
1262        &self,
1263        in_buff: *const u8,
1264        in_buff_len: usize,
1265        out_buff: *mut u8,
1266        out_buff_len: usize,
1267        rounding_mode: i32,
1268    ) -> i32;
1269
1270    /// Creates a float from an STNumber serialized value
1271    /// # Parameters
1272    /// * `in_buff` - Pointer to input STNumber buffer
1273    /// * `in_buff_len` - The length of the input buffer in bytes
1274    /// * `out_buff` - Pointer to output buffer where the float will be written
1275    /// * `out_buff_len` - The length of the output buffer in bytes
1276    /// * `rounding_mode` - Rounding mode to use for the operation
1277    /// # Returns
1278    /// 8 on success, error code otherwise
1279    ///
1280    /// # Safety
1281    /// Caller must ensure all pointer parameters point to valid memory
1282    unsafe fn float_from_stnumber(
1283        &self,
1284        in_buff: *const u8,
1285        in_buff_len: usize,
1286        out_buff: *mut u8,
1287        out_buff_len: usize,
1288        rounding_mode: i32,
1289    ) -> i32;
1290
1291    /// Converts a float to a signed integer
1292    /// # Parameters
1293    /// * `in_buff` - Pointer to input float value
1294    /// * `in_buff_len` - The length of the input float value in bytes
1295    /// * `out_buff` - Pointer to output buffer where the integer will be written
1296    /// * `out_buff_len` - The length of the output buffer in bytes
1297    /// * `rounding_mode` - Rounding mode to use for the operation
1298    /// # Returns
1299    /// 8 on success, error code otherwise
1300    ///
1301    /// # Safety
1302    /// Caller must ensure all pointer parameters point to valid memory
1303    unsafe fn float_to_int(
1304        &self,
1305        in_buff: *const u8,
1306        in_buff_len: usize,
1307        out_buff: *mut u8,
1308        out_buff_len: usize,
1309        rounding_mode: i32,
1310    ) -> i32;
1311
1312    /// Decomposes a float into its mantissa and exponent components
1313    /// # Parameters
1314    /// * `in_buff` - Pointer to input float value
1315    /// * `in_buff_len` - The length of the input float value in bytes
1316    /// * `mant_buff` - Pointer to output buffer where the mantissa will be written
1317    /// * `mant_buff_len` - The length of the mantissa output buffer in bytes
1318    /// * `exp_buff` - Pointer to output buffer where the exponent will be written
1319    /// * `exp_buff_len` - The length of the exponent output buffer in bytes
1320    /// # Returns
1321    /// 8 on success, error code otherwise
1322    ///
1323    /// # Safety
1324    /// Caller must ensure all pointer parameters point to valid memory
1325    unsafe fn float_to_mant_exp(
1326        &self,
1327        in_buff: *const u8,
1328        in_buff_len: usize,
1329        mant_buff: *mut u8,
1330        mant_buff_len: usize,
1331        exp_buff: *mut u8,
1332        exp_buff_len: usize,
1333    ) -> i32;
1334
1335    /// Compares two opaque float values
1336    /// # Parameters
1337    /// * `in_buff1` - Pointer to first float value
1338    /// * `in_buff1_len` - The length of the first float value in bytes
1339    /// * `in_buff2` - Pointer to second float value
1340    /// * `in_buff2_len` - The length of the second float value in bytes
1341    /// # Returns
1342    /// 0 if equal, 1 if first > second, 2 if first < second,
1343    ///
1344    /// # Safety
1345    /// Caller must ensure all pointer parameters point to valid memory
1346    unsafe fn float_cmp(
1347        &self,
1348        in_buff1: *const u8,
1349        in_buff1_len: usize,
1350        in_buff2: *const u8,
1351        in_buff2_len: usize,
1352    ) -> i32;
1353
1354    /// Adds two opaque float values
1355    /// # Parameters
1356    /// * `in_buff1` - Pointer to first float value
1357    /// * `in_buff1_len` - The length of the first float value in bytes
1358    /// * `in_buff2` - Pointer to second float value
1359    /// * `in_buff2_len` - The length of the second float value in bytes
1360    /// * `out_buff` - Pointer to output buffer where result will be written
1361    /// * `out_buff_len` - The length of the output buffer in bytes
1362    /// * `rounding_mode` - Rounding mode to use for the addition
1363    /// # Returns
1364    /// 8 on success, error code otherwise
1365    ///
1366    /// # Safety
1367    /// Caller must ensure all pointer parameters point to valid memory
1368    #[allow(clippy::too_many_arguments)]
1369    unsafe fn float_add(
1370        &self,
1371        in_buff1: *const u8,
1372        in_buff1_len: usize,
1373        in_buff2: *const u8,
1374        in_buff2_len: usize,
1375        out_buff: *mut u8,
1376        out_buff_len: usize,
1377        rounding_mode: i32,
1378    ) -> i32;
1379
1380    /// Subtracts two opaque float values
1381    /// # Parameters
1382    /// * `in_buff1` - Pointer to first float value
1383    /// * `in_buff1_len` - The length of the first float value in bytes
1384    /// * `in_buff2` - Pointer to second float value
1385    /// * `in_buff2_len` - The length of the second float value in bytes
1386    /// * `out_buff` - Pointer to output buffer where result will be written
1387    /// * `out_buff_len` - The length of the output buffer in bytes
1388    /// * `rounding_mode` - Rounding mode to use for the subtraction
1389    /// # Returns
1390    /// 8 on success, error code otherwise
1391    ///
1392    /// # Safety
1393    /// Caller must ensure all pointer parameters point to valid memory
1394    #[allow(clippy::too_many_arguments)]
1395    unsafe fn float_sub(
1396        &self,
1397        in_buff1: *const u8,
1398        in_buff1_len: usize,
1399        in_buff2: *const u8,
1400        in_buff2_len: usize,
1401        out_buff: *mut u8,
1402        out_buff_len: usize,
1403        rounding_mode: i32,
1404    ) -> i32;
1405
1406    /// Multiplies two opaque float values
1407    /// # Parameters
1408    /// * `in_buff1` - Pointer to first float value
1409    /// * `in_buff1_len` - The length of the first float value in bytes
1410    /// * `in_buff2` - Pointer to second float value
1411    /// * `in_buff2_len` - The length of the second float value in bytes
1412    /// * `out_buff` - Pointer to output buffer where result will be written
1413    /// * `out_buff_len` - The length of the output buffer in bytes
1414    /// * `rounding_mode` - Rounding mode to use for the multiplication
1415    /// # Returns
1416    /// 8 on success, error code otherwise
1417    ///
1418    /// # Safety
1419    /// Caller must ensure all pointer parameters point to valid memory
1420    #[allow(clippy::too_many_arguments)]
1421    unsafe fn float_mult(
1422        &self,
1423        in_buff1: *const u8,
1424        in_buff1_len: usize,
1425        in_buff2: *const u8,
1426        in_buff2_len: usize,
1427        out_buff: *mut u8,
1428        out_buff_len: usize,
1429        rounding_mode: i32,
1430    ) -> i32;
1431
1432    /// Divides two opaque float values
1433    /// # Parameters
1434    /// * `in_buff1` - Pointer to dividend float value
1435    /// * `in_buff1_len` - The length of the dividend float value in bytes
1436    /// * `in_buff2` - Pointer to divisor float value
1437    /// * `in_buff2_len` - The length of the divisor float value in bytes
1438    /// * `out_buff` - Pointer to output buffer where result will be written
1439    /// * `out_buff_len` - The length of the output buffer in bytes
1440    /// * `rounding_mode` - Rounding mode to use for the division
1441    /// # Returns
1442    /// 8 on success, error code otherwise
1443    ///
1444    /// # Safety
1445    /// Caller must ensure all pointer parameters point to valid memory
1446    #[allow(clippy::too_many_arguments)]
1447    unsafe fn float_div(
1448        &self,
1449        in_buff1: *const u8,
1450        in_buff1_len: usize,
1451        in_buff2: *const u8,
1452        in_buff2_len: usize,
1453        out_buff: *mut u8,
1454        out_buff_len: usize,
1455        rounding_mode: i32,
1456    ) -> i32;
1457
1458    /// Calculates the nth power of an opaque float value
1459    /// # Parameters
1460    /// * `in_buff` - Pointer to input float value
1461    /// * `in_buff_len` - The length of the input float value in bytes
1462    /// * `pow` - The power to calculate (e.g., 2 for square)
1463    /// * `out_buff` - Pointer to output buffer where result will be written
1464    /// * `out_buff_len` - The length of the output buffer in bytes
1465    /// * `rounding_mode` - Rounding mode to use for the operation
1466    /// # Returns
1467    /// 8 on success, error code otherwise
1468    ///
1469    /// # Safety
1470    /// Caller must ensure all pointer parameters point to valid memory
1471    unsafe fn float_pow(
1472        &self,
1473        in_buff: *const u8,
1474        in_buff_len: usize,
1475        pow: i32,
1476        out_buff: *mut u8,
1477        out_buff_len: usize,
1478        rounding_mode: i32,
1479    ) -> i32;
1480
1481    // #############################
1482    // Host Function Category: TRACE
1483    // #############################
1484
1485    /// Print to the trace log on XRPLd. Any XRPLd instance set to \"trace\" log level will see this.
1486    ///
1487    /// # Parameters
1488    /// - `msg_read_ptr`: A pointer to an array containing text characters (in utf8).
1489    /// - `msg_read_len`: The byte length of the text to send to the trace log.
1490    /// - `data_type`: A [`crate::host::trace::TraceDataType`] discriminant selecting how the host
1491    ///   reads the data buffer. Note that it sits between the message pair and the data pair.
1492    /// - `data_read_ptr`: A pointer to an array of bytes containing the data to print.
1493    /// - `data_read_len`: The byte length of that data. Numeric types require an exact width,
1494    ///   little-endian.
1495    ///
1496    /// Fire-and-forget: returns nothing and cannot fail from the guest's perspective.
1497    ///
1498    /// # Safety
1499    /// Caller must ensure all pointer parameters point to valid memory
1500    unsafe fn trace(
1501        &self,
1502        msg_read_ptr: *const u8,
1503        msg_read_len: usize,
1504        data_type: i32,
1505        data_read_ptr: *const u8,
1506        data_read_len: usize,
1507    );
1508}