thruput_xdr/invoke_flag.rs
1// -*-Rust-*-
2// Generated Code: DO NOT CHECK IN
3
4// Generated from xdrc commit: 6ab835b07c234abb4b0b50b61d687904727a4f32
5
6#![allow(non_camel_case_types)]
7#![allow(non_snake_case)]
8#![allow(non_upper_case_globals)]
9#![allow(unused_imports)]
10#![allow(dead_code)]
11#![allow(unused_variables)]
12#![allow(clippy::unnecessary_cast)]
13
14use crate::*;
15use core::option::Option;
16use core::ops::{Deref, DerefMut};
17
18#[cfg(feature = "std")]
19use std::io::{Read, Write};
20#[cfg(feature = "xdrs")]
21use xdrs::*;
22
23
24#[cfg(feature = "serde")]
25use ::serde::{{Serialize, Deserialize}};
26
27
28/// Flags that modify the behavior of a contract invocation.
29///
30/// These flags are used with the Invoke syscall to control how a subinvocation
31/// executes. They are combined using bitwise OR.
32///
33/// Note: InvokeFlagSet is NOT part of the Invocation struct itself, but is
34/// instead a parameter to the Invoke syscall. The root transaction invocation
35/// always has no flags set (equivalent to None).
36#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
37#[cfg_attr(feature = "serde", serde(transparent))]
38#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
39#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
40#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
41#[derive(Copy)]
42#[repr(transparent)]
43pub struct InvokeFlag(pub i32);
44
45impl InvokeFlag {
46 /// No special behavior (default).
47 pub const None: Self = Self(0);
48
49 /// Enable early conflict detection for parallel execution.
50 ///
51 /// Thruput executes transactions in parallel without observing other
52 /// transactions' writes. After execution, a two-phase commit process commits writes
53 /// to the database. If there's a conflict, the entire transaction aborts.
54 ///
55 /// TryInvoke pulls this conflict detection earlier: when a try_invoke frame
56 /// finishes, it performs two-phase commit lock acquisition immediately. If any lock fails,
57 /// the subinvocation frame reverts (but the caller can handle this gracefully).
58 ///
59 /// This is nondeterministic, so the two-phase commit result (a boolean) is appended to
60 /// the nondeterministic_bits in [`NondeterministicProposalData`] for deterministic
61 /// re-execution by validators.
62 pub const TryInvoke: Self = Self(0x00000001);
63
64 /// Prevent all state modifications in the subinvocation.
65 ///
66 /// The subinvocation can read storage but cannot write, deploy contracts,
67 /// or perform any other state-modifying operations.
68 pub const ReadOnly: Self = Self(0x00000002);
69
70 /// Execute the target contract's code in the caller's context.
71 ///
72 /// Similar to Ethereum's DELEGATECALL: the invoked code runs with the
73 /// caller's storage and address context, allowing library-like code reuse.
74 ///
75 /// TODO: This flag is not yet implemented. When implementing, provide
76 /// a comprehensive specification of what changes and what doesn't change in
77 /// a delegatecall frame. For example, GetMsgSender and GetCurrentAddress
78 /// should NOT change (they return the original caller and current address),
79 /// but storage operations should operate on the caller's storage. Document
80 /// the behavior of all syscalls in a delegatecall context.
81 pub const DelegateCall: Self = Self(0x00000004);
82}
83impl From<i32> for InvokeFlag {
84 fn from(v: i32) -> Self {
85 Self(v)
86 }
87}
88#[cfg(feature = "std")]
89impl core::fmt::Display for InvokeFlag {
90 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
91 match self.0 {
92 x if x == Self::None.0 => {
93 write!(f, "InvokeFlag::None")
94 },
95 x if x == Self::TryInvoke.0 => {
96 write!(f, "InvokeFlag::TryInvoke")
97 },
98 x if x == Self::ReadOnly.0 => {
99 write!(f, "InvokeFlag::ReadOnly")
100 },
101 x if x == Self::DelegateCall.0 => {
102 write!(f, "InvokeFlag::DelegateCall")
103 },
104 _ => {
105 write!(f, "InvokeFlag({})", self.0)
106 }
107 }
108 }
109}
110
111
112/// A bitset of InvokeFlag values.
113///
114/// Multiple flags can be combined using bitwise OR. For example:
115/// `ReadOnly | TryInvoke`
116///
117/// Unsigned because it holds bits, not a number, even though InvokeFlag,
118/// like every XDR enum, is a signed int.
119pub type InvokeFlagSet = u32;
120
121
122//
123// XDR internals below this point
124//
125
126