cloudflare / wirefilter

An execution engine for Wireshark-like filters
https://blog.cloudflare.com/building-fast-interpreters-in-rust/
MIT License
958 stars 85 forks source link

Issue with Lifetime Parameters in ExecutionContext #81

Closed ermakov-oleg closed 11 months ago

ermakov-oleg commented 11 months ago

Problem:

I'm relatively new to Rust and I've encountered an issue while using a library. It's possible that I might be doing something incorrectly:

The ExecutionContext is using the same lifetime parameter for both the schema and the context parameters.

Currently, my schema has a 'static lifetime, and the context is created for each request. However, the compiler demands that the context also has a 'static lifetime.

pub fn execute<'a>(&self, ctx: &ExecutionContext<'a>) -> bool {
   // `ctx` is a reference that is only valid in the method body
   // lifetime `'a` defined here
   self.filter.execute(ctx).unwrap_or(false)
   // `ctx` escapes the method body here
   // argument requires that `'a` must outlive `'static`
}

Is there something I might be doing incorrectly?

ermakov-oleg commented 11 months ago

When installing crate from the master branch, everything works as expected.