pub enum Filter {
Condition {
field: String,
op: FilterOp,
},
And(Vec<Filter>),
Or(Vec<Filter>),
Not(Box<Filter>),
}Expand description
Filtro de metadata con operadores lógicos.
Permite construir consultas complejas combinando condiciones simples con operadores AND/OR.
§Ejemplo
use minimemory::Filter;
// Filtro simple
let filter = Filter::eq("author", "Juan");
// Encadenamiento con AND
let filter = Filter::eq("category", "tech")
.and(Filter::gte("score", 0.5f64));
// Encadenamiento con OR
let filter = Filter::eq("status", "published")
.or(Filter::eq("status", "featured"));
// Múltiples filtros con all/any
let filter = Filter::all(vec![
Filter::eq("category", "tech"),
Filter::gte("score", 0.5f64),
]);
// Dot notation para campos anidados
let filter = Filter::eq("author.name", "Juan");Variants§
Condition
Condición simple: campo + operador
And(Vec<Filter>)
AND lógico: todas las condiciones deben cumplirse
Or(Vec<Filter>)
OR lógico: al menos una condición debe cumplirse
Not(Box<Filter>)
NOT lógico: invierte el resultado
Implementations§
Source§impl Filter
impl Filter
Sourcepub fn eq(field: impl Into<String>, value: impl Into<MetadataValue>) -> Self
pub fn eq(field: impl Into<String>, value: impl Into<MetadataValue>) -> Self
Crea un filtro de igualdad simple.
§Ejemplo
use minimemory::query::Filter;
let filter = Filter::eq("author", "Juan");Sourcepub fn ne(field: impl Into<String>, value: impl Into<MetadataValue>) -> Self
pub fn ne(field: impl Into<String>, value: impl Into<MetadataValue>) -> Self
Crea un filtro de desigualdad.
Sourcepub fn gt(field: impl Into<String>, value: impl Into<MetadataValue>) -> Self
pub fn gt(field: impl Into<String>, value: impl Into<MetadataValue>) -> Self
Crea un filtro “mayor que”.
Sourcepub fn gte(field: impl Into<String>, value: impl Into<MetadataValue>) -> Self
pub fn gte(field: impl Into<String>, value: impl Into<MetadataValue>) -> Self
Crea un filtro “mayor o igual que”.
Sourcepub fn lt(field: impl Into<String>, value: impl Into<MetadataValue>) -> Self
pub fn lt(field: impl Into<String>, value: impl Into<MetadataValue>) -> Self
Crea un filtro “menor que”.
Sourcepub fn lte(field: impl Into<String>, value: impl Into<MetadataValue>) -> Self
pub fn lte(field: impl Into<String>, value: impl Into<MetadataValue>) -> Self
Crea un filtro “menor o igual que”.
Sourcepub fn range(
field: impl Into<String>,
min: Option<impl Into<MetadataValue>>,
max: Option<impl Into<MetadataValue>>,
) -> Self
pub fn range( field: impl Into<String>, min: Option<impl Into<MetadataValue>>, max: Option<impl Into<MetadataValue>>, ) -> Self
Crea un filtro de rango (min <= x <= max).
Sourcepub fn in_list(
field: impl Into<String>,
values: Vec<impl Into<MetadataValue>>,
) -> Self
pub fn in_list( field: impl Into<String>, values: Vec<impl Into<MetadataValue>>, ) -> Self
Crea un filtro “valor en lista”.
Sourcepub fn not_in_list(
field: impl Into<String>,
values: Vec<impl Into<MetadataValue>>,
) -> Self
pub fn not_in_list( field: impl Into<String>, values: Vec<impl Into<MetadataValue>>, ) -> Self
Crea un filtro “valor NO en lista”.
Sourcepub fn contains(field: impl Into<String>, substr: impl Into<String>) -> Self
pub fn contains(field: impl Into<String>, substr: impl Into<String>) -> Self
Crea un filtro “campo contiene substring”.
Sourcepub fn starts_with(field: impl Into<String>, prefix: impl Into<String>) -> Self
pub fn starts_with(field: impl Into<String>, prefix: impl Into<String>) -> Self
Crea un filtro “campo empieza con”.
Sourcepub fn ends_with(field: impl Into<String>, suffix: impl Into<String>) -> Self
pub fn ends_with(field: impl Into<String>, suffix: impl Into<String>) -> Self
Crea un filtro “campo termina con”.
Sourcepub fn regex(field: impl Into<String>, pattern: impl Into<String>) -> Self
pub fn regex(field: impl Into<String>, pattern: impl Into<String>) -> Self
Crea un filtro de regex sobre un campo string.
§Ejemplo
use minimemory::Filter;
// Matches strings starting with "Hello"
Filter::regex("title", "^Hello");Sourcepub fn not_exists(field: impl Into<String>) -> Self
pub fn not_exists(field: impl Into<String>) -> Self
Crea un filtro “campo no existe”.
Sourcepub fn and(self, other: Filter) -> Self
pub fn and(self, other: Filter) -> Self
Combina este filtro con otro usando AND.
§Ejemplo
use minimemory::Filter;
let filter = Filter::eq("category", "tech")
.and(Filter::gt("score", 0.5f64));Trait Implementations§
Auto Trait Implementations§
impl Freeze for Filter
impl RefUnwindSafe for Filter
impl Send for Filter
impl Sync for Filter
impl Unpin for Filter
impl UnsafeUnpin for Filter
impl UnwindSafe for Filter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more