1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//! Traits for decompression variant construction.
//!
//! These traits enable ergonomic client-side construction of `RentFreeDecompressAccount`
//! from seeds and compressed account data.
use Error;
use ProgramError as Error;
/// Trait for seeds that can construct a compressed account variant.
///
/// Implemented by generated `XxxSeeds` structs (e.g., `UserRecordSeeds`).
/// The macro generates impls that deserialize account data and verify seeds match.
///
/// # Example (generated code)
/// ```ignore
/// impl IntoVariant<RentFreeAccountVariant> for UserRecordSeeds {
/// fn into_variant(self, data: &[u8]) -> Result<RentFreeAccountVariant, Error> {
/// RentFreeAccountVariant::user_record(data, self)
/// }
/// }
/// ```
/// Trait for CToken account variant types that can construct a full variant with token data.
///
/// Implemented by generated `TokenAccountVariant` enum.
/// The macro generates the impl that wraps variant + token_data into `RentFreeAccountVariant`.
///
/// # Example (generated code)
/// ```ignore
/// impl IntoCTokenVariant<RentFreeAccountVariant> for TokenAccountVariant {
/// fn into_ctoken_variant(self, token_data: TokenData) -> RentFreeAccountVariant {
/// RentFreeAccountVariant::CTokenData(CTokenData {
/// variant: self,
/// token_data,
/// })
/// }
/// }
/// ```
///
/// Type parameter `T` is typically `light_token::compat::TokenData`.