radix_transactions/validation/
id_allocator.rs1use crate::internal_prelude::*;
2
3#[derive(Default, Debug, Clone, PartialEq, Eq)]
4pub struct ManifestIdAllocator {
5 next_bucket_id: u32,
6 next_proof_id: u32,
7 next_address_reservation_id: u32,
8 next_address_id: u32,
9 next_intent_id: u32,
10}
11
12impl ManifestIdAllocator {
13 pub fn new() -> Self {
14 Self::default()
15 }
16
17 pub fn new_bucket_id(&mut self) -> ManifestBucket {
23 let id = self.next_bucket_id;
24 self.next_bucket_id += 1;
25 ManifestBucket(id)
26 }
27
28 pub fn new_proof_id(&mut self) -> ManifestProof {
29 let id = self.next_proof_id;
30 self.next_proof_id += 1;
31 ManifestProof(id)
32 }
33
34 pub fn new_address_reservation_id(&mut self) -> ManifestAddressReservation {
35 let id = self.next_address_reservation_id;
36 self.next_address_reservation_id += 1;
37 ManifestAddressReservation(id)
38 }
39
40 pub fn new_address_id(&mut self) -> ManifestNamedAddress {
41 let id = self.next_address_id;
42 self.next_address_id += 1;
43 ManifestNamedAddress(id)
44 }
45
46 pub fn new_named_intent_id(&mut self) -> ManifestNamedIntent {
47 let id = self.next_intent_id;
48 self.next_intent_id += 1;
49 ManifestNamedIntent(id)
50 }
51}