pub struct MongoSetComparison<V, C> { /* private fields */ }mongo only.Expand description
A SetFilter’s storage-side twin: the same eight operators, over the ELEMENT type this
database stores the members as.
§MongoDB has no set type either, so the split is in the OPERATORS
A set and a sequence occupy the same BSON array, exactly as they occupy the same Postgres
ARRAY and the same JSON column, and what differs is which operators are emitted against it.
Two of them have no direct operator at all and are built:
| operator | rendering |
|---|---|
encloses | $all — every operand is a member, order- and multiplicity-blind |
overlaps | $in — some member is an operand |
has_element | $eq — the bare member match |
enclosed_by | $type: "array" and $not: {$elemMatch: {$nin: […]}} — no member lies outside |
eq | those two AND $all: mutual containment, which is what set equality is |
ne | $nor of the equality document, because negating a conjunction is a disjunction |
any / count | the sequence kind’s, unchanged |
§$type: "array" is not decoration, and $not is why
A subset test says no member lies outside the operand, and a document with NO such field
satisfies that vacuously — measured, {tags: {$not: {$elemMatch: {$nin: [1,2]}}}} returns the
document with no tags and the one whose tags is a string. Every other backend answers a
missing collection with no row: Postgres’s <@ on a NULL column is NULL. So the guard is what
makes this backend answer the same question as the others, and with it the same measurement
returns exactly the arrays that are subsets.
It is NOT applied to encloses or overlaps, and that is the guard being written where it is
needed rather than everywhere: $all and $in are already bracketed by having an operand to
compare against, so a missing field fails them on its own.
§An EMPTY operand is where $all stops meaning what set theory means
Every set encloses the empty set, and Postgres agrees — tags @> '{}' is true of every array —
but {tags: {$all: []}} matches NO document. So an empty encloses renders the guard ALONE,
which is the vacuous truth stated exactly: this field is an array. An empty eq drops the
$all for the same reason and keeps the rest, leaving is an array, and no member lies outside
nothing — the empty array, and measured to be exactly it.
That is deliberately NOT the reading $in: [] gets, and the difference is the operators’
own: an empty intersection is empty, so overlaps: [] matching nothing is the answer rather
than a degeneration.
Implementations§
Source§impl<V, C> MongoSetComparison<V, C>
impl<V, C> MongoSetComparison<V, C>
Sourcepub const fn is_empty(&self) -> bool
pub const fn is_empty(&self) -> bool
True while NO operator slot is set, so a lowering would write nothing for this field.
A present ELEMENT slot counts even when the comparison inside it is empty, and the
QUANTIFIER is why — see ListFilter::is_empty, whose
reading this mirrors: an element scope opened with no predicate in it asks whether the
collection HAS a member. A present CARDINALITY slot holding an empty comparison does not
count, for the other half of that reading: nothing quantifies it, so an empty one asks
nothing and writes nothing.
Sourcepub const fn conjuncts(&self) -> usize
pub const fn conjuncts(&self) -> usize
How many operators this comparison writes — one per set slot.
A set membership slot counts even when the list inside it is empty: in_: [] is the
operator present with an operand that asks for no documents, where an absent in_ asks
for every one. A present ELEMENT slot counts ONCE however many operators the comparison
inside it writes, because those land inside one $elemMatch. A present CARDINALITY slot
counts what IT counts, because its expressions land beside this comparison’s own keys.
Sourcepub const fn has_element(&self) -> Option<&V>
pub const fn has_element(&self) -> Option<&V>
The has_element operand, in the type this database stores.
Sourcepub fn encloses(&self) -> Option<&[V]>
pub fn encloses(&self) -> Option<&[V]>
The encloses operands, in the type this database stores.
Sourcepub fn enclosed_by(&self) -> Option<&[V]>
pub fn enclosed_by(&self) -> Option<&[V]>
The enclosed_by operands, in the type this database stores.
Sourcepub fn overlaps(&self) -> Option<&[V]>
pub fn overlaps(&self) -> Option<&[V]>
The overlaps operands, in the type this database stores.
Sourcepub const fn any(&self) -> Option<&C>
pub const fn any(&self) -> Option<&C>
The comparison ONE member of this collection is asked under any, or None while the operator is absent.
Sourcepub const fn count(&self) -> Option<&MongoCountComparison<i64>>
pub const fn count(&self) -> Option<&MongoCountComparison<i64>>
The comparison this collection’s LENGTH is asked under count, or None while the operator is absent.
Source§impl<V, C> MongoSetComparison<V, C>
impl<V, C> MongoSetComparison<V, C>
Sourcepub fn try_from_filter_with<D, VF, E, F>(
filter: SetFilter<D, VF>,
f: F,
) -> Result<Self, MongoCollectionCrossingError<E, <C as TryFromFilter<VF::Mapped>>::Error>>
pub fn try_from_filter_with<D, VF, E, F>( filter: SetFilter<D, VF>, f: F, ) -> Result<Self, MongoCollectionCrossingError<E, <C as TryFromFilter<VF::Mapped>>::Error>>
Cross a SetFilter into this comparison through ONE converter — see
MongoListComparison::try_from_filter_with for what the single converter is and why a
declaration gets one.
§Errors
As try_from_filter_with_element, with f’s refusal
standing for both levels of operand.
Sourcepub fn try_from_filter_with_element<D, VF, E, F, X, G>(
filter: SetFilter<D, VF>,
f: F,
g: G,
) -> Result<Self, MongoCollectionCrossingError<E, X>>
pub fn try_from_filter_with_element<D, VF, E, F, X, G>( filter: SetFilter<D, VF>, f: F, g: G, ) -> Result<Self, MongoCollectionCrossingError<E, X>>
Cross a SetFilter into this comparison, converting each ELEMENT with f and the element
FILTER with g.
§Errors
As MongoListComparison::try_from_filter_with_element, whose three failures these are.
Trait Implementations§
Source§impl<V: MongoCarrier, C: ComplexComparison<Mongo>> ComplexComparison<Mongo> for MongoSetComparison<V, C>
Three of the five whole-collection operators are one key each and two are BUILT — see
MongoSetComparison for the table and for what $type: "array" closes.
impl<V: MongoCarrier, C: ComplexComparison<Mongo>> ComplexComparison<Mongo> for MongoSetComparison<V, C>
Three of the five whole-collection operators are one key each and two are BUILT — see
MongoSetComparison for the table and for what $type: "array" closes.
§This kind OVERFLOWS its own entry, and it is the second in the family to
eq and enclosed_by both write $type and $not, and eq and encloses both write $all,
so a comparison setting more than one of the three has keys no single operator document can
hold. The accumulator’s fold is the answer, exactly as it is for
MongoTextComparison’s twelve affix slots reaching two keys: the
first merges and the rest become $and branches. What that costs is one redundant branch where
two slots write the SAME guard — an $and of a true thing already said — and it is correct
rather than minimal.
Source§impl<V, C> Default for MongoSetComparison<V, C>
impl<V, C> Default for MongoSetComparison<V, C>
impl<V: PartialEq, C: PartialEq> StructuralPartialEq for MongoSetComparison<V, C>
Source§impl<D, VF, V: TryFrom<D>, C: TryFromFilter<VF>> TryFromFilter<SetFilter<D, VF>> for MongoSetComparison<V, C>
The identity crossing for a set.
impl<D, VF, V: TryFrom<D>, C: TryFromFilter<VF>> TryFromFilter<SetFilter<D, VF>> for MongoSetComparison<V, C>
The identity crossing for a set.
§Errors
Source§type Error = MongoCollectionCrossingError<<V as TryFrom<D>>::Error, <C as TryFromFilter<VF>>::Error>
type Error = MongoCollectionCrossingError<<V as TryFrom<D>>::Error, <C as TryFromFilter<VF>>::Error>
Auto Trait Implementations§
impl<V, C> Freeze for MongoSetComparison<V, C>
impl<V, C> RefUnwindSafe for MongoSetComparison<V, C>
impl<V, C> Send for MongoSetComparison<V, C>
impl<V, C> Sync for MongoSetComparison<V, C>
impl<V, C> Unpin for MongoSetComparison<V, C>
impl<V, C> UnsafeUnpin for MongoSetComparison<V, C>
impl<V, C> UnwindSafe for MongoSetComparison<V, C>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.impl<T> Fruit for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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 moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.