diff --git a/src/expr.rs b/src/expr.rs index f5811ae..5640e4d 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -1,6 +1,8 @@ use serde::{Deserialize, Serialize}; use std::collections::HashSet; +use crate::stmt::Statement; + #[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)] #[serde(untagged)] /// Expressions are the building blocks of (most) statements. @@ -26,7 +28,7 @@ pub enum NamedExpression { Concat(Vec), /// This object constructs an anonymous set. /// For mappings, an array of arrays with exactly two elements is expected. - Set(Vec), + Set(Vec), Map(Box), Prefix(Prefix), @@ -59,6 +61,19 @@ pub struct Map { pub data: Expression, } +#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)] +#[serde(untagged)] +/// Item in an anonymous set. +pub enum SetItem{ + /// A set item containing a single expression. + Element(Expression), + /// A set item mapping two expressions. + Mapping(Expression, Expression), + /// A set item mapping an expression to a statement. + MappingStatement(Expression, Statement), +} + + #[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)] #[serde(rename = "prefix")] /// Construct an IPv4 or IPv6 prefix consisting of address part in `addr` and prefix length in `len`. diff --git a/src/stmt.rs b/src/stmt.rs index f16c8fd..0230c2a 100644 --- a/src/stmt.rs +++ b/src/stmt.rs @@ -74,7 +74,7 @@ pub enum Statement { /// This represents an xt statement from xtables compat interface. /// Sadly, at this point, it is not possible to provide any further information about its content. - XT(Option), + XT(Option), } #[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)] @@ -118,10 +118,10 @@ pub struct Match { pub struct Counter { #[serde(skip_serializing_if = "Option::is_none")] /// Packets counted. - pub packets: Option, + pub packets: Option, #[serde(skip_serializing_if = "Option::is_none")] /// Bytes counted. - pub bytes: Option, + pub bytes: Option, } #[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]