Skip to content

Conversation

@marmeladema
Copy link
Collaborator

This allows to remove the 's lifetime in most of the codebase which should also simplify the life of wirefilter users.

It also enables downstream crates to implement deserialization of filter AST with serde using TLS stored scheme or similar tricks.

let (function, rest) = Function::lex_with(input, parser.scheme)?;
impl<'i> LexWith<'i, &FilterParser<'_>> for FunctionCallExpr {
fn lex_with(input: &'i str, parser: &FilterParser<'_>) -> LexResult<'i, Self> {
let (function, rest) = FunctionRef::lex_with(input, parser.scheme)?;
Copy link
Member

Choose a reason for hiding this comment

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

Similar here, should lex_with be implemented on Function, so we don't need to call .to_owned() on the FunctionRef?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't have a strong opinion. It's just going to move the call to .to_owned() to the caller so its not clear what we would gain.


#[inline]
pub(crate) fn get_field_value_unchecked(&self, field: Field<'_>) -> &LhsValue<'_> {
pub(crate) fn get_field_value_unchecked(&self, field: &Field) -> &LhsValue<'_> {
Copy link
Member

Choose a reason for hiding this comment

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

Should this take a FieldRef instead of a &Field (and similarly for get_list_matcher_unchecked below)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think so, since this is used specifically to get the value from a Field stored in the ast, it seems wasteful to have to convert to a FieldRef before.

/// An enum to represent an entry inside a [`Scheme`](struct@Scheme).
/// It can be either a [`Field`](struct@Field) or a [`Function`](struct@Function).
#[derive(Debug)]
pub enum Identifier<'s> {
Copy link
Member

Choose a reason for hiding this comment

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

Should this be called IdentifierRef now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Its not exposed anymore since #122 so I am not sure it matters much.
I actually wonder if we should just get rid of that type entirely.

@marmeladema marmeladema force-pushed the scheme-no-ref branch 2 times, most recently from 83387ac to 564268d Compare March 24, 2025 13:10
This allows to remove the `'s` lifetime in most of the codebase
which should also simplify the life of wirefilter users.

It also enables downstream crates to implement deserialization of
filter AST with serde using TLS stored scheme or similar tricks.
@marmeladema marmeladema merged commit fa2fba7 into master Apr 7, 2025
7 checks passed
@marmeladema marmeladema deleted the scheme-no-ref branch April 7, 2025 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants