holochain_integrity_types/
rate_limit.rs1use holochain_serialized_bytes::prelude::*;
4
5pub type RateBucketId = u8;
7
8pub type RateUnits = u8;
10
11pub type RateBytes = u8;
13
14pub type RateBucketCapacity = u32;
16
17#[derive(
19 Debug,
20 Clone,
21 serde::Serialize,
22 serde::Deserialize,
23 PartialEq,
24 Eq,
25 SerializedBytes,
26 Hash,
27 PartialOrd,
28 Ord,
29)]
30#[allow(missing_docs)]
31pub struct RateWeight {
32 pub bucket_id: RateBucketId,
33 pub units: RateUnits,
34}
35
36impl Default for RateWeight {
37 fn default() -> Self {
38 Self {
39 bucket_id: 255,
40 units: 0,
41 }
42 }
43}
44
45#[derive(
47 Debug,
48 Clone,
49 serde::Serialize,
50 serde::Deserialize,
51 PartialEq,
52 Eq,
53 SerializedBytes,
54 Hash,
55 PartialOrd,
56 Ord,
57)]
58#[allow(missing_docs)]
59pub struct EntryRateWeight {
60 pub bucket_id: RateBucketId,
61 pub units: RateUnits,
62 pub rate_bytes: RateBytes,
63}
64
65impl Default for EntryRateWeight {
66 fn default() -> Self {
67 Self {
68 bucket_id: 255,
69 units: 0,
70 rate_bytes: 0,
71 }
72 }
73}
74
75impl From<EntryRateWeight> for RateWeight {
76 fn from(w: EntryRateWeight) -> Self {
77 Self {
78 bucket_id: w.bucket_id,
79 units: w.units,
80 }
81 }
82}