holochain_integrity_types/
rate_limit.rs1use holochain_serialized_bytes::prelude::*;
4
5use crate::{Create, CreateLink, Delete, Entry, Update};
6
7#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, SerializedBytes, Debug)]
10pub enum WeighInput {
11 Link(CreateLink<()>),
13 Create(Create<()>, Entry),
15 Update(Update<()>, Entry),
17 Delete(Delete<()>),
19}
20
21pub type RateBucketId = u8;
23
24pub type RateUnits = u8;
26
27pub type RateBytes = u8;
29
30pub type RateBucketCapacity = u32;
32
33#[derive(
35 Debug,
36 Clone,
37 serde::Serialize,
38 serde::Deserialize,
39 PartialEq,
40 Eq,
41 SerializedBytes,
42 Hash,
43 PartialOrd,
44 Ord,
45)]
46#[allow(missing_docs)]
47pub struct RateWeight {
48 pub bucket_id: RateBucketId,
49 pub units: RateUnits,
50}
51
52impl Default for RateWeight {
53 fn default() -> Self {
54 Self {
55 bucket_id: 255,
56 units: 0,
57 }
58 }
59}
60
61#[derive(
63 Debug,
64 Clone,
65 serde::Serialize,
66 serde::Deserialize,
67 PartialEq,
68 Eq,
69 SerializedBytes,
70 Hash,
71 PartialOrd,
72 Ord,
73)]
74#[allow(missing_docs)]
75pub struct EntryRateWeight {
76 pub bucket_id: RateBucketId,
77 pub units: RateUnits,
78 pub rate_bytes: RateBytes,
79}
80
81impl Default for EntryRateWeight {
82 fn default() -> Self {
83 Self {
84 bucket_id: 255,
85 units: 0,
86 rate_bytes: 0,
87 }
88 }
89}
90
91impl From<EntryRateWeight> for RateWeight {
92 fn from(w: EntryRateWeight) -> Self {
93 Self {
94 bucket_id: w.bucket_id,
95 units: w.units,
96 }
97 }
98}