Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing things #12

Merged
merged 6 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use serde::{Deserialize, Serialize};
use std::collections::HashSet;

use crate::stmt::Statement;
use crate::stmt::Counter;

#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
Expand Down Expand Up @@ -355,9 +356,10 @@ pub enum Verdict {
/// Explicitly set element object.
pub struct Elem {
pub val: Box<Expression>,
pub timeout: u32,
pub expires: u32,
pub comment: String,
pub timeout: Option<u32>,
pub expires: Option<u32>,
pub comment: Option<String>,
pub counter: Option<Counter>,
}

#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
Expand Down
6 changes: 6 additions & 0 deletions src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ pub struct Set {
pub gc_interval: Option<u32>,
#[serde(skip_serializing_if = "Option::is_none")]
pub size: Option<u32>,
#[serde(skip_serializing_if = "Option::is_none")]
pub comment: Option<String>,
}

#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
Expand Down Expand Up @@ -232,6 +234,9 @@ pub enum SetType {
#[serde(rename = "mark")]
#[strum(serialize="mark")]
Mark,
#[serde(rename = "ifname")]
#[strum(serialize="ifname")]
Ifname,
}

#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
Expand All @@ -249,6 +254,7 @@ pub enum SetFlag {
Constant,
Interval,
Timeout,
Dynamic,
jwhb marked this conversation as resolved.
Show resolved Hide resolved
}

#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
Expand Down
1 change: 1 addition & 0 deletions tests/helper_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ fn example_ruleset() -> schema::Nftables {
timeout: None,
gc_interval: None,
size: None,
comment: None,
}));
// add element to set
batch.add(schema::NfListObject::Element(schema::Element {
Expand Down