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;
34use crate::sfield::SField;
35
36impl LedgerObjectFieldGetter for Array {
37    #[inline]
38    fn get_from_current_ledger_obj<const CODE: i32>(_field: SField<Self, CODE>) -> Result<Self> {
39        // This should never be called - Array is a placeholder type
40        unreachable!("Array is a placeholder type and cannot be retrieved from ledger objects")
41    }
42
43    #[inline]
44    fn get_from_ledger_obj<const CODE: i32>(
45        _slot: i32,
46        _field: SField<Self, CODE>,
47    ) -> Result<Self> {
48        // This should never be called - Array is a placeholder type
49        unreachable!("Array is a placeholder type and cannot be retrieved from ledger objects")
50    }
51
52    #[inline]
53    fn get_from_current_ledger_obj_optional<const CODE: i32>(
54        _field: SField<Self, CODE>,
55    ) -> 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    #[inline]
61    fn get_from_ledger_obj_optional<const CODE: i32>(
62        _slot: i32,
63        _field: SField<Self, CODE>,
64    ) -> Result<Option<Self>> {
65        // This should never be called - Array is a placeholder type
66        unreachable!("Array is a placeholder type and cannot be retrieved from ledger objects")
67    }
68}
69
70impl LedgerObjectFieldGetter for Object {
71    #[inline]
72    fn get_from_current_ledger_obj<const CODE: i32>(_field: SField<Self, CODE>) -> Result<Self> {
73        // This should never be called - Object is a placeholder type
74        unreachable!("Object is a placeholder type and cannot be retrieved from ledger objects")
75    }
76
77    #[inline]
78    fn get_from_ledger_obj<const CODE: i32>(
79        _slot: i32,
80        _field: SField<Self, CODE>,
81    ) -> Result<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
86    #[inline]
87    fn get_from_current_ledger_obj_optional<const CODE: i32>(
88        _field: SField<Self, CODE>,
89    ) -> Result<Option<Self>> {
90        // This should never be called - Object is a placeholder type
91        unreachable!("Object is a placeholder type and cannot be retrieved from ledger objects")
92    }
93
94    #[inline]
95    fn get_from_ledger_obj_optional<const CODE: i32>(
96        _slot: i32,
97        _field: SField<Self, CODE>,
98    ) -> Result<Option<Self>> {
99        // This should never be called - Object is a placeholder type
100        unreachable!("Object is a placeholder type and cannot be retrieved from ledger objects")
101    }
102}