Skip to main content

thruput_xdr/
storage_item.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
29/// The type of a storage item.
30#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
31#[cfg_attr(feature = "serde", serde(transparent))]
32#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
33#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
34#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
35#[derive(Copy)]
36#[repr(transparent)]
37pub struct StorageItemType(pub i32);
38
39impl StorageItemType {
40    pub const kItemTypeBytestring: Self = Self(0);
41    pub const kItemTypeNonnegativeInt: Self = Self(1);
42    pub const kItemTypeRetrocausalQueue: Self = Self(2);
43    pub const kItemTypeReplayCacheData: Self = Self(3);
44    pub const kItemTypeAuthData: Self = Self(4);
45    pub const kItemTypeDeployedContractHash: Self = Self(5);
46
47    // 
48    // This will be removed when we get rid of the old db interface.
49    
50    #[doc(hidden)]pub const kItemTypeDeleted: Self = Self(-1);
51}
52impl From<i32> for StorageItemType {
53    fn from(v: i32) -> Self {
54        Self(v)
55    }
56}
57#[cfg(feature = "std")]
58impl core::fmt::Display for StorageItemType {
59    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
60        match self.0 {
61            x if x == Self::kItemTypeBytestring.0 => {
62                write!(f, "StorageItemType::kItemTypeBytestring")
63            },
64            x if x == Self::kItemTypeNonnegativeInt.0 => {
65                write!(f, "StorageItemType::kItemTypeNonnegativeInt")
66            },
67            x if x == Self::kItemTypeRetrocausalQueue.0 => {
68                write!(f, "StorageItemType::kItemTypeRetrocausalQueue")
69            },
70            x if x == Self::kItemTypeReplayCacheData.0 => {
71                write!(f, "StorageItemType::kItemTypeReplayCacheData")
72            },
73            x if x == Self::kItemTypeAuthData.0 => {
74                write!(f, "StorageItemType::kItemTypeAuthData")
75            },
76            x if x == Self::kItemTypeDeployedContractHash.0 => {
77                write!(f, "StorageItemType::kItemTypeDeployedContractHash")
78            },
79            x if x == Self::kItemTypeDeleted.0 => {
80                write!(f, "StorageItemType::kItemTypeDeleted")
81            },
82            _ => {
83                write!(f, "StorageItemType({})", self.0)
84            }
85        }
86    }
87}
88
89
90/// The largest bytestring the wire format admits, and so the ceiling on
91/// `kConfigParamMaxBytestringLen`. Raising this is a protocol upgrade;
92/// raising the configured limit is not.
93pub const kBytestringCeilingLen : u32 = 65000;
94
95/// The limit in force when a configuration does not state one.
96pub const kDefaultMaxBytestringLen : u32 = 1024;
97
98/// An arbitrary value, stored as an opaque string of bytes.
99///
100/// Bounded by the ceiling, not by the limit in force: what a chain permits is
101/// enforced where a bytestring is written rather than where it is decoded.
102pub type Bytestring = BytesM::<kBytestringCeilingLen>;
103
104/// The value at every storage key is one of the following data types.
105///
106/// [`StorageDelta`]s are modifications that are applied to these StorageItem objects.
107///
108/// Contracts do not generally directly load these values, but can access them via the typed
109/// system call interface provided by the Thruput runtime.
110/// For example, a contract can call `BytestringGet`, which will return either a Bytestring value or
111/// an error if the storage key does not exist or contains a different type.
112#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
113#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
114#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
115#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
116#[repr(i32)]
117#[non_exhaustive]
118pub enum StorageItem {
119    /// An arbitrary value, stored as an opaque string of bytes.
120    // case kItemTypeBytestring:
121    //   Bytestring bytestring;
122    kItemTypeBytestring { bytestring: Bytestring } = StorageItemType::kItemTypeBytestring.0 as i32,
123    /// A nonnegative integer, stored as a 128-bit value.
124    ///
125    /// This can be stored at any [`StorageKey`] of type `ContractData`.
126    /// This type is also used to store the free native token balance at
127    /// storage key type `FreeNativeTokenBalance`.
128    // case kItemTypeNonnegativeInt:
129    //   int128_xdr nnint;
130    kItemTypeNonnegativeInt { nnint: int128_xdr } = StorageItemType::kItemTypeNonnegativeInt.0 as i32,
131    /// A retrocausal multi-producer, single-consumer queue.
132    /// Transactions can only insert entries into the queue or consume entries one by one
133    /// from the queue, so the whole queue is generally not loaded all at once.
134    // case kItemTypeRetrocausalQueue:
135    //   VecM<QueueEntry> queue_entries;
136    kItemTypeRetrocausalQueue { queue_entries: VecM<QueueEntry> } = StorageItemType::kItemTypeRetrocausalQueue.0 as i32,
137    /// A set of [`Uniquifier`]s that have been used by the current address.
138    /// Transactions can only insert a Uniquifier, not read the whole set.
139    ///
140    /// This is the type stored at storage key type `ReplayCache`.
141    /// It cannot be stored at any other storage key.
142    // case kItemTypeReplayCacheData:
143    //   VecM<Uniquifier> active_uniquifiers;
144    kItemTypeReplayCacheData { active_uniquifiers: VecM<Uniquifier> } = StorageItemType::kItemTypeReplayCacheData.0 as i32,
145    /// The authorization data for the current address.
146    ///
147    /// This is the type stored at storage key type `AuthData`.
148    /// It cannot be stored at any other storage key.
149    // case kItemTypeAuthData:
150    //   AddressAuthData auth_data;
151    kItemTypeAuthData { auth_data: AddressAuthData } = StorageItemType::kItemTypeAuthData.0 as i32,
152    /// The hash of the deployed contract for the current address.
153    ///
154    /// This is the type stored at storage key type `Metadata`.
155    /// It cannot be stored at any other storage key.
156    // case kItemTypeDeployedContractHash:
157    //   DeployedContractHash deployed_contract_hash;
158    kItemTypeDeployedContractHash { deployed_contract_hash: DeployedContractHash } = StorageItemType::kItemTypeDeployedContractHash.0 as i32,
159    
160}
161// 
162// This is the type that is actually sent over the network from the database to the executor.
163// This type strips out complex types (the replay cache and retrocausal queue) that the
164// executor does not need to load.
165// The types are filled in, as the executor does need to know the type of an item even
166// without knowing the contents.
167
168#[doc(hidden)]
169#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
170#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
171#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
172#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
173#[repr(i32)]
174#[non_exhaustive]
175pub enum WireStorageItem {
176    // case kItemTypeBytestring:
177    //   Bytestring bytestring;
178    kItemTypeBytestring { bytestring: Bytestring } = StorageItemType::kItemTypeBytestring.0 as i32,
179    // case kItemTypeNonnegativeInt:
180    //   int128_xdr nnint;
181    kItemTypeNonnegativeInt { nnint: int128_xdr } = StorageItemType::kItemTypeNonnegativeInt.0 as i32,
182    // case kItemTypeAuthData:
183    //   AddressAuthData auth_data;
184    kItemTypeAuthData { auth_data: AddressAuthData } = StorageItemType::kItemTypeAuthData.0 as i32,
185    // case kItemTypeRetrocausalQueue:
186    //   RetrocausalQueueMetadata metadata;
187    kItemTypeRetrocausalQueue { metadata: RetrocausalQueueMetadata } = StorageItemType::kItemTypeRetrocausalQueue.0 as i32,
188    // case kItemTypeReplayCacheData:
189    //   void;
190    kItemTypeReplayCacheData = StorageItemType::kItemTypeReplayCacheData.0 as i32,
191    // case kItemTypeDeployedContractHash:
192    //   DeployedContractHash deployed_contract_hash;
193    kItemTypeDeployedContractHash { deployed_contract_hash: DeployedContractHash } = StorageItemType::kItemTypeDeployedContractHash.0 as i32,
194    
195}
196
197/// The types of changes accumulated by a transaction that will be applied to the database
198/// if the transaction commits.
199#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
200#[cfg_attr(feature = "serde", serde(transparent))]
201#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
202#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
203#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
204#[derive(Copy)]
205#[repr(transparent)]
206pub struct StorageDeltaType(pub i32);
207
208impl StorageDeltaType {
209    pub const kDeltaTypeBytestringSet: Self = Self(0);
210    pub const kDeltaTypeNonnegativeIntSetAdd: Self = Self(1);
211    pub const kDeltaTypeDelete: Self = Self(2);
212    pub const kDeltaTypeRetrocausalQueue: Self = Self(3);
213    pub const kDeltaTypeNonnegativeIntAdd: Self = Self(5);
214    pub const kDeltaTypeAuthDataChange: Self = Self(6);
215    pub const kDeltaTypeDeployContract: Self = Self(7);
216    pub const kDeltaTypeConsumeUniquifier: Self = Self(8);
217}
218impl From<i32> for StorageDeltaType {
219    fn from(v: i32) -> Self {
220        Self(v)
221    }
222}
223#[cfg(feature = "std")]
224impl core::fmt::Display for StorageDeltaType {
225    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
226        match self.0 {
227            x if x == Self::kDeltaTypeBytestringSet.0 => {
228                write!(f, "StorageDeltaType::kDeltaTypeBytestringSet")
229            },
230            x if x == Self::kDeltaTypeNonnegativeIntSetAdd.0 => {
231                write!(f, "StorageDeltaType::kDeltaTypeNonnegativeIntSetAdd")
232            },
233            x if x == Self::kDeltaTypeDelete.0 => {
234                write!(f, "StorageDeltaType::kDeltaTypeDelete")
235            },
236            x if x == Self::kDeltaTypeRetrocausalQueue.0 => {
237                write!(f, "StorageDeltaType::kDeltaTypeRetrocausalQueue")
238            },
239            x if x == Self::kDeltaTypeNonnegativeIntAdd.0 => {
240                write!(f, "StorageDeltaType::kDeltaTypeNonnegativeIntAdd")
241            },
242            x if x == Self::kDeltaTypeAuthDataChange.0 => {
243                write!(f, "StorageDeltaType::kDeltaTypeAuthDataChange")
244            },
245            x if x == Self::kDeltaTypeDeployContract.0 => {
246                write!(f, "StorageDeltaType::kDeltaTypeDeployContract")
247            },
248            x if x == Self::kDeltaTypeConsumeUniquifier.0 => {
249                write!(f, "StorageDeltaType::kDeltaTypeConsumeUniquifier")
250            },
251            _ => {
252                write!(f, "StorageDeltaType({})", self.0)
253            }
254        }
255    }
256}
257
258
259#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
260#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
261#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
262#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
263#[repr(C)]
264pub struct AuthDataChangeSigner {
265    pub public_key_id: u32,
266    pub public_key: PublicKeyConfigOpt,
267}
268
269#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
270#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
271#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
272#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
273#[repr(C)]
274pub struct AuthDataChangeArgs {
275    pub auth_data_change_signers: VecM<AuthDataChangeSigner, kMaxSigners>,
276    pub new_required_weight: Option<Weight>,
277}
278
279#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
280#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
281#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
282#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
283#[repr(C)]
284pub struct NonnegativeInt128SetAddArgs {
285    pub set_value: int128_xdr,
286    pub add_value: int128_xdr,
287}
288
289#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
290#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
291#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
292#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
293#[repr(C)]
294pub struct ConsumeUniquifierArgs {
295    pub uniquifier: Uniquifier,
296}
297
298/// One change (of possibly many) accumulated by a transaction to be applied to the database
299/// if the transaction commits.
300///
301/// Each operation (other than `kDeltaTypeDelete`) will create an item of one specific type
302/// at the storage key it is applied to.  `kDeltaTypeDelete` will delete the item.
303/// These writes overwrite an existing item at the storage key, if any.
304/// Two deltas conflict with each other if they would create different types of items
305/// at the same storage key (or if one would delete an item that the other would create).
306///
307/// Beyond that, each subtype of storage delta has its own conflict resolution rules.
308#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
309#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
310#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
311#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
312#[repr(i32)]
313#[non_exhaustive]
314pub enum StorageDelta {
315    /// Creates a bytestring item, with the supplied value.
316    ///
317    /// Item Type: `kItemTypeBytestring`
318    ///
319    /// Conflicts:
320    ///   - Will conflict with any other delta that creates a *different* item at the same storage key.
321    // case kDeltaTypeBytestringSet:
322    //   Bytestring bytestring;
323    kDeltaTypeBytestringSet { bytestring: Bytestring } = StorageDeltaType::kDeltaTypeBytestringSet.0 as i32,
324    /// Creates a nonnegative integer item.
325    /// The value of the int will be equal to the `set_value`, plus the sum of all the `add_value`s supplied
326    /// by this delta and all NonnegativeInt128SetAdd and NonnegativeInt128Add deltas in the same block.
327    ///
328    /// Item Type: `kItemTypeNonnegativeInt`
329    ///
330    /// Conflicts:
331    ///   - Will conflict with any NonnegativeIntSetAdd delta with a different `set_value`.
332    ///   - NonnegativeIntAdd deltas are equivalent to a NonnegativeIntSetAdd delta with a `set_value` equal
333    ///     to the value of the item at the start of the block (if it is a nonnegative integer) or 0 otherwise.
334    ///     If that implicit set_value is not the same as the supplied `set_value`, the deltas will conflict.
335    ///   - At the end of a block, the value will be `set_value` plus the sum of all `add_values` supplied by this
336    ///     delta and other deltas from the same block.  Thruput maintains the property that this expression
337    ///     does not overflow a 128-bit integer, and that that value is always at least `min(set_value, 0)`.
338    // case kDeltaTypeNonnegativeIntSetAdd:
339    //   NonnegativeInt128SetAddArgs nnint;
340    kDeltaTypeNonnegativeIntSetAdd { nnint: NonnegativeInt128SetAddArgs } = StorageDeltaType::kDeltaTypeNonnegativeIntSetAdd.0 as i32,
341    /// Adds the supplied value to the nonnegative integer item at the storage key.
342    /// This type is equivalent to a NonnegativeIntSetAdd delta with a `set_value`
343    /// equal to the value of the item at the start of the block (if it is a nonnegative integer) or 0 otherwise.
344    /// This delta type enables a more efficient implementation of common nonnegative integer use cases (like token balances).
345    ///
346    /// Item Type: `kItemTypeNonnegativeInt`
347    ///
348    /// Conflicts:
349    ///   - Same as NonnegativeIntSetAdd deltas.
350    // case kDeltaTypeNonnegativeIntAdd:
351    //   int128_xdr nnint_add;
352    kDeltaTypeNonnegativeIntAdd { nnint_add: int128_xdr } = StorageDeltaType::kDeltaTypeNonnegativeIntAdd.0 as i32,
353    /// Deletes the item at the storage key.
354    ///
355    /// Item Type: None (deletes the item at the storage key)
356    ///
357    /// Conflicts:
358    ///   - Will conflict with any other delta that creates a *different* item at the same storage key.
359    // case kDeltaTypeDelete:
360    //   void;
361    kDeltaTypeDelete = StorageDeltaType::kDeltaTypeDelete.0 as i32,
362    /// Consumes or inserts entries into the retrocausal queue.
363    ///
364    /// Item Type: `kItemTypeRetrocausalQueue`
365    ///
366    /// Conflicts:
367    ///   - Insertions do not conflict with each other.
368    ///     TODO: we may impose limits on the number of entries that can be inserted in one block.
369    ///   - Consuming entries conflicts with other consumption deltas in the same block.
370    // case kDeltaTypeRetrocausalQueue:
371    //   RetrocausalQueueDelta retrocausal_queue;
372    kDeltaTypeRetrocausalQueue { retrocausal_queue: RetrocausalQueueDelta } = StorageDeltaType::kDeltaTypeRetrocausalQueue.0 as i32,
373    /// Changes the authorization data for the current address.
374    ///
375    /// Item Type: `kItemTypeAuthData`
376    ///
377    /// Conflicts:
378    ///   - Will conflict with any other auth change delta in the same block.
379    // case kDeltaTypeAuthDataChange:
380    //   AuthDataChangeArgs auth_data_change;
381    kDeltaTypeAuthDataChange { auth_data_change: AuthDataChangeArgs } = StorageDeltaType::kDeltaTypeAuthDataChange.0 as i32,
382    /// Deploys a new contract for the current address.
383    ///
384    /// Item Type: `kItemTypeDeployedContractHash`
385    ///
386    /// Conflicts:
387    ///   - None.  The semantics of how contract deployment addresses are calculated (see [`ContractDeploymentHashPreimage`])
388    ///     if two transactions deploy a contract to the same address,
389    ///     then both transactions are deploying the exact same contract.
390    // case kDeltaTypeDeployContract:
391    //   DeployedContractHash deployed_contract_hash;
392    kDeltaTypeDeployContract { deployed_contract_hash: DeployedContractHash } = StorageDeltaType::kDeltaTypeDeployContract.0 as i32,
393    /// Add a [`Uniquifier`] to the replay cache.
394    ///
395    /// Item Type: kItemTypeReplayCacheData
396    ///
397    /// Conflicts:
398    ///   - Will conflict with any other attempt to consume the same [`Uniquifier`].
399    // case kDeltaTypeConsumeUniquifier:
400    //   ConsumeUniquifierArgs consume_uniquifier_args;
401    kDeltaTypeConsumeUniquifier { consume_uniquifier_args: ConsumeUniquifierArgs } = StorageDeltaType::kDeltaTypeConsumeUniquifier.0 as i32,
402    
403}
404
405/// Maximum heights with an unexpired consumed uniquifier in a cache.
406pub const kReplayCacheHeightsMaxLen : u32 = 4000;
407
408/// Maximum unexpired consumed uniquifiers allowed per height in a cache.
409pub const kReplayCacheNoncesMaxLen : u32 = 8000;
410// 
411// Information about the number of nonces stored at each height of a
412// ReplayCache. Tracked in the ReplayCacheMetadata so nonce GC can
413// determine the change cost after some heights are deleted without
414// having to load the nonces at that height.
415
416#[doc(hidden)]
417#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
418#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
419#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
420#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
421#[repr(C)]
422pub struct ReplayCacheHeightCount {
423    pub height: BlockHeight,
424    pub nonce_count: u32,
425}
426// 
427
428#[doc(hidden)]
429#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
430#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
431#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
432#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
433#[repr(C)]
434pub struct ReplayCacheMetadata {
435    // Total count of all nonces in this ReplayCache across all heights.
436    pub size: i64,
437    // Sorted list of heights with active nonces and count at each.
438    pub heights: VecM<ReplayCacheHeightCount, kReplayCacheNoncesMaxLen>,
439}
440// 
441
442#[doc(hidden)]
443#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
444#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
445#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
446#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
447#[repr(C)]
448pub struct ReplayCacheData {
449    // Sorted list of nonces for a particular height of a ReplayCache.
450    pub nonces: VecM<u64, kReplayCacheNoncesMaxLen>,
451}
452
453/// Flags that can be set on a storage delta to modify its behavior.
454/// Multiple flags can be combined using bitwise OR.
455#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
456#[cfg_attr(feature = "serde", serde(transparent))]
457#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
458#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
459#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
460#[derive(Copy)]
461#[repr(transparent)]
462pub struct StorageDeltaFlags(pub i32);
463
464impl StorageDeltaFlags {
465    pub const None: Self = Self(0);
466
467    /// Forces the delta to acquire an exclusive lock on the item at the storage key,
468    /// regardless of any other conflict resolution rules.
469    pub const ExclusiveLock: Self = Self(0x00000001);
470}
471impl From<i32> for StorageDeltaFlags {
472    fn from(v: i32) -> Self {
473        Self(v)
474    }
475}
476#[cfg(feature = "std")]
477impl core::fmt::Display for StorageDeltaFlags {
478    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
479        match self.0 {
480            x if x == Self::None.0 => {
481                write!(f, "StorageDeltaFlags::None")
482            },
483            x if x == Self::ExclusiveLock.0 => {
484                write!(f, "StorageDeltaFlags::ExclusiveLock")
485            },
486            _ => {
487                write!(f, "StorageDeltaFlags({})", self.0)
488            }
489        }
490    }
491}
492
493
494/// A bitset of StorageDeltaFlags values.
495///
496/// Unsigned because it holds bits, not a number, even though
497/// StorageDeltaFlags, like every XDR enum, is a signed int.
498pub type StorageDeltaFlagSet = u32;
499
500/// The combined unit of storage modification sent to the database from the executor.
501/// A delta with a set of flags, applied to a specific entry in the database.
502#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
503#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
504#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
505#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
506#[repr(C)]
507pub struct FlaggedStorageDelta {
508    // TODO: The addrkey field is likely repetitive when sending
509    // many deltas to the database.
510    // possibly we can readjust this data structure, if raw bandwidth becomes
511    // important.
512    pub addrkey: AddressAndKey,
513    pub delta: StorageDelta,
514    pub flags: StorageDeltaFlagSet,
515}
516
517
518//
519// XDR internals below this point
520//
521
522impl StorageItem {
523    #[allow(clippy::match_single_binding)]
524    pub fn r#type(&self) -> StorageItemType {
525        match self {
526            
527            _ => (unsafe { *(self as *const Self as *const i32) }).into(),
528        }
529    }
530}
531
532impl WireStorageItem {
533    #[allow(clippy::match_single_binding)]
534    pub fn r#type(&self) -> StorageItemType {
535        match self {
536            
537            _ => (unsafe { *(self as *const Self as *const i32) }).into(),
538        }
539    }
540}
541
542impl StorageDelta {
543    #[allow(clippy::match_single_binding)]
544    pub fn r#type(&self) -> StorageDeltaType {
545        match self {
546            
547            _ => (unsafe { *(self as *const Self as *const i32) }).into(),
548        }
549    }
550}
551
552