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 documentation for Expressions #76

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add documentation for Expressions #76

wants to merge 1 commit into from

Conversation

jwhb
Copy link
Contributor

@jwhb jwhb commented Oct 25, 2024

This is a major improvement to the expr module:

  • Adds doc comments throughout the module
  • Adds Default impls for all structs in expr
  • (breaking) Adds SocketAttr enum type for Socket key.

@jwhb jwhb self-assigned this Oct 25, 2024
@jwhb jwhb added documentation Improvements or additions to documentation enhancement New feature or request labels Oct 25, 2024
@jwhb jwhb added this to the v0.6.0 milestone Oct 25, 2024
@jwhb jwhb linked an issue Oct 25, 2024 that may be closed by this pull request
@jwhb jwhb force-pushed the jwhb-expr-docs branch 4 times, most recently from 36f2faa to a4fdf39 Compare January 9, 2025 20:30
Adds impls of Default for several expr types.
Adds doc comments throughout expr module.

BREAKING CHANGE: Adds SocketAttr enum type for Socket key.
@jwhb jwhb marked this pull request as ready for review January 9, 2025 20:40
@jwhb jwhb requested a review from JKRhb January 9, 2025 20:40
Copy link
Contributor

@JKRhb JKRhb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from a few nits: LGTM! :)

Verdict(Verdict<'a>),
}

#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
/// Wrapper for non-immediate `Expression`s.
/// Wrapper for non-immediate [Expressions](Expression).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this should be lowercase, for the sake of consistency?

Suggested change
/// Wrapper for non-immediate [Expressions](Expression).
/// Wrapper for non-immediate [expressions](Expression).

Copy link
Contributor Author

@jwhb jwhb Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. Also I noticed that rustdoc triggers a warning for redundant labels (e.g. [Flag](Flag))

Fib(Fib),
/// Explicitly set element object, in case `timeout`, `expires` or `comment`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Explicitly set element object, in case `timeout`, `expires` or `comment`
/// Explicitly set element object, in case `timeout`, `expires`, or `comment`

Elem(Elem<'a>),
/// Construct a reference to packet’s socket.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Construct a reference to packet’s socket.
/// Construct a reference to a packet’s socket.

pub addr: Box<Expression<'a>>,
/// A prefix length.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// A prefix length.
/// The prefix length.

Socket(Socket<'a>),
/// Perform OS fingerprinting.
/// This expression is typically used in the LHS of a [match](crate::stmt::Match) statement.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the second sentence/explanation should be separated by an empty line.

Suggested change
/// This expression is typically used in the LHS of a [match](crate::stmt::Match) statement.
///
/// This expression is typically used in the LHS of a [match](crate::stmt::Match) statement.

#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
/// Represents a `meta` key for packet meta data.
///
/// See also: <https://wiki.nftables.org/wiki-nftables/index.php/Matching_packet_metainformation>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// See also: <https://wiki.nftables.org/wiki-nftables/index.php/Matching_packet_metainformation>
/// See [this page](https://wiki.nftables.org/wiki-nftables/index.php/Matching_packet_metainformation)
for more information.

Oifkind,
/// Output interface group.
Oifgroup,
/// Input bridge interface name.
Ibridgename,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, should these rather be sorted alphabetically?

@@ -11,7 +11,7 @@
/// Contains Batch object to be used to prepare Nftables payloads.
pub mod batch;

/// Contains Expressions.
/// Contains [Expressions](crate::expr::Expression).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Contains [Expressions](crate::expr::Expression).
/// Contains [expressions](crate::expr::Expression).

Transparent,
/// Match on the socket mark (`SOL_SOCKET`, `SO_MARK`).
Mark,
/// Indicates whether the socket is wildcard-bound (e.g. 0.0.0.0 or ::0).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think :: does not need a 0 suffix, right?

Suggested change
/// Indicates whether the socket is wildcard-bound (e.g. 0.0.0.0 or ::0).
/// Indicates whether the socket is wildcard-bound (e.g. 0.0.0.0 or ::).

Comment on lines +668 to +670
/// Similar to jump, but the current position is not pushed to the call
/// stack, meaning that after the new chain evaluation will continue at the
/// last chain instead of the one containing the goto statement.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Similar to jump, but the current position is not pushed to the call
/// stack, meaning that after the new chain evaluation will continue at the
/// last chain instead of the one containing the goto statement.
/// Similar to jump, but the current position is not pushed to the call
/// stack.
///
/// That means that after the new chain evaluation will continue at the
/// last chain instead of the one containing the goto statement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants