Skip to main content

re_query/
lib.rs

1//! Caching datastructures for `re_query`.
2
3mod cache;
4mod cache_stats;
5mod latest_all;
6mod latest_at;
7mod range;
8mod storage_engine;
9
10pub mod clamped_zip;
11pub mod range_zip;
12
13use re_chunk::ComponentIdentifier;
14
15pub use self::cache::{QueryCache, QueryCacheHandle, QueryCacheKey};
16pub use self::cache_stats::{QueryCacheStats, QueryCachesStats};
17pub use self::clamped_zip::*;
18pub use self::latest_all::{LatestAllComponentResults, LatestAllResults};
19pub(crate) use self::latest_at::LatestAtCache;
20pub use self::latest_at::LatestAtResults;
21pub(crate) use self::range::RangeCache;
22pub use self::range::RangeResults;
23pub use self::range_zip::*;
24pub use self::storage_engine::{
25    StorageEngine, StorageEngineArcReadGuard, StorageEngineLike, StorageEngineReadGuard,
26    StorageEngineWriteGuard,
27};
28
29pub mod external {
30    pub use {paste, seq_macro};
31}
32
33// ---
34
35#[derive(Debug, Clone, Copy)]
36pub struct ComponentNotFoundError(pub re_types_core::ComponentType);
37
38impl std::fmt::Display for ComponentNotFoundError {
39    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
40        f.write_fmt(format_args!("Could not find component: {}", self.0))
41    }
42}
43
44impl std::error::Error for ComponentNotFoundError {}
45
46#[derive(thiserror::Error, Debug)]
47pub enum QueryError {
48    #[error("Tried to access a column that doesn't exist")]
49    BadAccess,
50
51    #[error("Could not find primary component: {0}")]
52    PrimaryNotFound(ComponentIdentifier),
53
54    #[error(transparent)]
55    ComponentNotFound(#[from] ComponentNotFoundError),
56
57    #[error("Tried to access component of type '{actual:?}' using component '{requested:?}'")]
58    TypeMismatch {
59        actual: re_types_core::ComponentType,
60        requested: re_types_core::ComponentType,
61    },
62
63    #[error("Error deserializing: {0}")]
64    DeserializationError(#[from] re_types_core::DeserializationError),
65
66    #[error("Error serializing: {0}")]
67    SerializationError(#[from] re_types_core::SerializationError),
68
69    #[error("Not implemented")]
70    NotImplemented,
71
72    #[error("{}", re_error::format(.0))]
73    Other(#[from] anyhow::Error),
74}
75
76const _: () = assert!(
77    std::mem::size_of::<QueryError>() <= 80,
78    "Error type is too large. Try to reduce its size by boxing some of its variants.",
79);
80
81pub type Result<T> = std::result::Result<T, QueryError>;