Files
inbuxa-server/crates/store/src/dispatch/mod.rs
T
jcoffey-dev 7dae9b29fd Import upstream v0.16.22, stripped
Upstream commit: 474dd0229cb20cf513036619781ed97bd8073c3f
Enterprise-only files removed or emptied: 63
Enterprise-only snippets removed: 117 in 50 files
Dangling module declarations removed: 5
Cargo edits turning enterprise off: 14
Verification: clean
Enterprise feature gates left for rebuilt features: 19 in 18 files

Produced by tools/fork/strip.py. The full report is in docs/fork/strip-reports/ on main.
2026-09-18 10:21:56 -07:00

108 lines
2.2 KiB
Rust

/*
* SPDX-FileCopyrightText: 2020 Stalwart Labs LLC <[email protected]>
*
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
*/
use crate::Store;
use roaring::RoaringBitmap;
pub mod blob;
pub mod lookup;
pub mod search;
pub mod store;
impl Store {
pub fn id(&self) -> &'static str {
match self {
#[cfg(feature = "sqlite")]
Self::SQLite(_) => "sqlite",
#[cfg(feature = "foundation")]
Self::FoundationDb(_) => "foundationdb",
#[cfg(feature = "postgres")]
Self::PostgreSQL(_) => "postgresql",
#[cfg(feature = "mysql")]
Self::MySQL(_) => "mysql",
#[cfg(feature = "rocks")]
Self::RocksDb(_) => "rocksdb",
Self::Ephemeral(_) => "ephemeral",
Self::None => "none",
}
}
}
#[allow(clippy::len_without_is_empty)]
pub trait DocumentSet: Sync + Send {
fn min(&self) -> u32;
fn max(&self) -> u32;
fn contains(&self, id: u32) -> bool;
fn len(&self) -> usize;
fn iterate(&self) -> impl Iterator<Item = u32>;
}
impl DocumentSet for RoaringBitmap {
fn min(&self) -> u32 {
self.min().unwrap_or(0)
}
fn max(&self) -> u32 {
self.max().map(|m| m + 1).unwrap_or(0)
}
fn contains(&self, id: u32) -> bool {
self.contains(id)
}
fn len(&self) -> usize {
self.len() as usize
}
fn iterate(&self) -> impl Iterator<Item = u32> {
self.iter()
}
}
impl DocumentSet for Vec<u32> {
fn contains(&self, id: u32) -> bool {
self.binary_search(&id).is_ok()
}
fn min(&self) -> u32 {
self.first().copied().unwrap_or(0)
}
fn max(&self) -> u32 {
self.last().copied().map(|m| m + 1).unwrap_or(0)
}
fn len(&self) -> usize {
self.len()
}
fn iterate(&self) -> impl Iterator<Item = u32> {
self.iter().copied()
}
}
impl DocumentSet for () {
fn min(&self) -> u32 {
0
}
fn max(&self) -> u32 {
u32::MAX
}
fn contains(&self, _: u32) -> bool {
true
}
fn len(&self) -> usize {
0
}
fn iterate(&self) -> impl Iterator<Item = u32> {
std::iter::empty()
}
}