fix(stmt)!: match anonymous and named quotas

This commit is contained in:
wiegratz
2024-11-12 11:45:02 +01:00
parent ae72346ade
commit 61ba8eaec6
+12 -4
View File
@@ -33,10 +33,8 @@ pub enum Statement {
/// anonymous or named counter.
Counter(Counter),
Mangle(Mangle),
Quota(Quota),
#[serde(rename = "quota")]
/// reference to a named quota object
QuotaRef(String),
/// anonymous or named quota.
Quota(QuotaOrQuotaRef),
// TODO: last
Limit(Limit),
@@ -155,6 +153,16 @@ pub struct Mangle {
pub value: Expression,
}
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
/// Represents an anonymous or named quota object.
pub enum QuotaOrQuotaRef {
/// Anonymous quota object.
Quota(Quota),
/// Reference to a named quota object.
QuotaRef(String),
}
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
/// Creates an anonymous quota which lives in the rule it appears in.
pub struct Quota {