radix_common/data/scrypto/
custom_traversal.rs

1use crate::internal_prelude::*;
2
3#[derive(Debug, Clone, PartialEq, Eq)]
4pub struct ScryptoCustomTerminalValueRef(pub ScryptoCustomValue);
5
6impl CustomTerminalValueRef for ScryptoCustomTerminalValueRef {
7    type CustomValueKind = ScryptoCustomValueKind;
8
9    fn custom_value_kind(&self) -> Self::CustomValueKind {
10        self.0.get_custom_value_kind()
11    }
12}
13
14#[derive(Copy, Debug, Clone, PartialEq, Eq)]
15pub enum ScryptoCustomTraversal {}
16
17impl CustomTraversal for ScryptoCustomTraversal {
18    type CustomValueKind = ScryptoCustomValueKind;
19    type CustomTerminalValueRef<'de> = ScryptoCustomTerminalValueRef;
20
21    fn read_custom_value_body<'de, R>(
22        custom_value_kind: Self::CustomValueKind,
23        reader: &mut R,
24    ) -> Result<Self::CustomTerminalValueRef<'de>, DecodeError>
25    where
26        R: BorrowingDecoder<'de, Self::CustomValueKind>,
27    {
28        // TODO: copy-free decoding for better performance
29        ScryptoCustomValue::decode_body_with_value_kind(
30            reader,
31            ValueKind::Custom(custom_value_kind),
32        )
33        .map(ScryptoCustomTerminalValueRef)
34    }
35}