filter

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package filter provides a BPF-inspired expression language for filtering decoded NMEA 2000 frames by field values.

Expressions support boolean logic (&&, ||, !), comparison operators (==, !=, <, >, <=, >=), and dotted field access for lookup sub-fields.

Example expressions:

"pgn == 130310 && water_temperature < 280"
"register.name == \"State of Charge\""
"pgn == 61184 || pgn == 130310"

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EvalContext

type EvalContext struct {
	PGN     uint32
	Src     uint8
	Dst     uint8
	Prio    uint8
	Decoded any               // decoded PGN struct, nil if unavailable
	Lookups map[string]string // from LookupFields(), nil if unavailable
}

EvalContext provides the data a filter expression is evaluated against.

type Filter

type Filter struct {
	// contains filtered or unexported fields
}

Filter is a compiled display filter expression.

func Compile

func Compile(expr string) (*Filter, error)

Compile parses and compiles a filter expression string. Returns an error if the expression is syntactically invalid.

func (*Filter) Match

func (f *Filter) Match(ctx *EvalContext) bool

Match evaluates the filter against the given context.

func (*Filter) NeedsDecode

func (f *Filter) NeedsDecode() bool

NeedsDecode returns true if the expression references decoded fields (anything other than pgn, src, dst, prio).

func (*Filter) String

func (f *Filter) String() string

String returns a human-readable representation of the filter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL