namib-project / nftables-rs

Safe abstraction for nftables JSON API (libnftables-json).
https://crates.io/crates/nftables
Apache License 2.0
32 stars 15 forks source link

Various memory optimizations #94

Open hack3ric opened 2 weeks ago

hack3ric commented 2 weeks ago

See each commit message for details.

These are a lot of breaking changes, so please take your time to check if they are properly done :)

hack3ric commented 2 weeks ago

Oops, this failed to build on Rust <1.79 because the compiler cannot decide if [Expression]: ToOwned:

error[E0277]: the trait bound `[SetItem]: ToOwned` is not satisfied in `Expression`
   --> src/stmt.rs:245:14
    |
245 |     pub dev: Option<Expression>,
    |              ^^^^^^^^^^^^^^^^^^ within `Expression`, the trait `ToOwned` is not implemented for `[SetItem]`, which is required by `Expression: Sized`
    |
    = help: the trait `ToOwned` is implemented for `[T]`
note: required because it appears within the type `Expression`
   --> src/expr.rs:10:10
    |
10  | pub enum Expression {
    |          ^^^^^^^^^^
note: required by an implicit `Sized` bound in `std::option::Option`
   --> /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/option.rs:572:1

...and many, many similar errors

If bumping MSRV to version this recent is not acceptable, keeping Vecs would probably fix this issue.

hack3ric commented 1 week ago

Fixed MSRV build and clippy. Please have another look :)

jwhb commented 6 days ago

Amazing @hack3ric!

Please allow us some more days to review it.

hack3ric commented 6 days ago

Added one commit that lifts 'static restriction on borrowed values, but added a lot of lifetimes, and updated examples in README as well.

hack3ric commented 5 days ago

Clippy issue should be fixed now.

hack3ric commented 4 days ago

FYI I have another patch ready for upstream, but it depends on this PR: https://github.com/namib-project/nftables-rs/commit/52902cd79b44b2582cb57beb4c137be66660a7ba. I will submit another PR after this and I hope this too can get into v0.6.0 too :)