Skip to main content

xrpl_wasm_stdlib/core/ledger_objects/
array_object.rs

1//! Placeholder types for array and object SFields.
2//!
3//! These types are used as placeholders in SField definitions for array and object types
4//! that cannot be directly retrieved from ledger objects. They are primarily used within
5//! `Location` for navigating nested structures.
6
7use crate::host::Result;
8
9/// Placeholder type for array SFields.
10///
11/// Array types in XRPL (like Signers, Memos, etc.) cannot be directly retrieved
12/// as complete values. Instead, they are used within `Location` to navigate to
13/// specific array elements.
14///
15/// This type implements `FieldGetter` as a no-op to satisfy the trait bound,
16/// but should not be used to actually retrieve values.
17#[derive(Debug, Clone, Copy, Eq, PartialEq)]
18pub struct Array;
19
20/// Placeholder type for object SFields.
21///
22/// Object types in XRPL (like Memo, SignerEntry, etc.) cannot be directly retrieved
23/// as complete values. Instead, they are used within `Location` to navigate to
24/// specific object fields.
25///
26/// This type implements `FieldGetter` as a no-op to satisfy the trait bound,
27/// but should not be used to actually retrieve values.
28#[derive(Debug, Clone, Copy, Eq, PartialEq)]
29pub struct Object;
30
31// Implement FieldGetter for Array and Object as no-ops
32// These are placeholder types and should not be used for actual field retrieval
33use crate::core::ledger_objects::LedgerObjectFieldGetter;
34
35impl LedgerObjectFieldGetter for Array {
36    #[inline]
37    fn get_from_current_ledger_obj(_field_code: i32) -> Result<Self> {
38        // This should never be called - Array is a placeholder type
39        unreachable!("Array is a placeholder type and cannot be retrieved from ledger objects")
40    }
41
42    #[inline]
43    fn get_from_ledger_obj(_slot: i32, _field_code: i32) -> Result<Self> {
44        // This should never be called - Array is a placeholder type
45        unreachable!("Array is a placeholder type and cannot be retrieved from ledger objects")
46    }
47
48    #[inline]
49    fn get_from_current_ledger_obj_optional(_field_code: i32) -> Result<Option<Self>> {
50        // This should never be called - Array is a placeholder type
51        unreachable!("Array is a placeholder type and cannot be retrieved from ledger objects")
52    }
53
54    #[inline]
55    fn get_from_ledger_obj_optional(_slot: i32, _field_code: i32) -> Result<Option<Self>> {
56        // This should never be called - Array is a placeholder type
57        unreachable!("Array is a placeholder type and cannot be retrieved from ledger objects")
58    }
59}
60
61impl LedgerObjectFieldGetter for Object {
62    #[inline]
63    fn get_from_current_ledger_obj(_field_code: i32) -> Result<Self> {
64        // This should never be called - Object is a placeholder type
65        unreachable!("Object is a placeholder type and cannot be retrieved from ledger objects")
66    }
67
68    #[inline]
69    fn get_from_ledger_obj(_slot: i32, _field_code: i32) -> Result<Self> {
70        // This should never be called - Object is a placeholder type
71        unreachable!("Object is a placeholder type and cannot be retrieved from ledger objects")
72    }
73
74    #[inline]
75    fn get_from_current_ledger_obj_optional(_field_code: i32) -> Result<Option<Self>> {
76        // This should never be called - Object is a placeholder type
77        unreachable!("Object is a placeholder type and cannot be retrieved from ledger objects")
78    }
79
80    #[inline]
81    fn get_from_ledger_obj_optional(_slot: i32, _field_code: i32) -> Result<Option<Self>> {
82        // This should never be called - Object is a placeholder type
83        unreachable!("Object is a placeholder type and cannot be retrieved from ledger objects")
84    }
85}