xrpl_wasm_stdlib/host/
host_bindings_trait.rs

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