FilterLogic
This class provides a trait for implementing complex filtering logic to determine whether specific items should be included or omitted during processing. It evaluates items based on explicit inclusion rules, default filter settings, and dynamic include/exclude sets or dictionaries provided at runtime. The class manages the recursive propagation of these filters, returning instructions on how to handle nested values.
Methods
explicit_include()
def explicit_include(
value: T
) - > bool
whether an index/key is explicitly included, this is combined with call-time include below
Parameters
| Name | Type | Description |
|---|---|---|
| value | T | The index or key to check for explicit inclusion |
Returns
| Type | Description |
|---|---|
bool | True if the value is explicitly marked for inclusion in the schema, False otherwise |
default_filter()
def default_filter(
value: T
) - > bool
default decision on whether to include the item at a given index/key
Parameters
| Name | Type | Description |
|---|---|---|
| value | T | The index or key to evaluate against the default filter logic |
Returns
| Type | Description |
|---|---|
bool | The default inclusion status for the item when no specific include/exclude rules apply |
filter()
def filter(
py_key: impl IntoPyObject< 'py > + Copy,
int_key: T,
include: Option< &Bound< 'py, PyAny > >,
exclude: Option< &Bound< 'py, PyAny > >
) - > PyResult< NextFilters< 'py > >
Determines whether to omit or include a value at a specific index based on hierarchical include and exclude rules. It calculates the next level of filters to be passed down to nested objects.
Parameters
| Name | Type | Description |
|---|---|---|
| py_key | impl IntoPyObject< 'py > + Copy | The Python-compatible representation of the key used for lookups in include/exclude sets or dicts |
| int_key | T | The internal representation of the key used for schema-level explicit inclusion checks |
| include | Option< &Bound< 'py, PyAny > > | An optional set or dictionary defining which keys should be included in the output |
| exclude | Option< &Bound< 'py, PyAny > > | An optional set or dictionary defining which keys should be excluded from the output |
Returns
| Type | Description |
|---|---|
PyResult< NextFilters< 'py > > | Returns Ok(None) if the item should be omitted, or Ok(Some(IncludeExclude)) containing the filters for the next recursion level |