linkrs-query 0.1.0

Query engine, parser, and executor for Linkrs
Documentation
//! Bridge for awaiting async coordinator operations from operator threads.
//!
//! Operators execute on arbitrary worker threads that may or may not run
//! inside a tokio runtime. Remote engines require the ambient runtime's
//! reactor and timers, so blocking waits must go through the shared
//! runtime-aware helper instead of a bare executor block-on.

#[cfg(any(feature = "vector", feature = "fulltext"))]
use linkrs_core::error::QueryError;

/// Drive `future` to completion on the calling thread, mapping both the
/// bridging failure and the operation failure into a labeled query error.
#[cfg(any(feature = "vector", feature = "fulltext"))]
pub(crate) fn wait<F, T, E>(label: &str, future: F) -> Result<T, QueryError>
where
    F: std::future::Future<Output = Result<T, E>> + Send,
    T: Send,
    E: Send + std::fmt::Display,
{
    let label = format!("{label} failed");
    linkrs_sync::runtime::block_on_ambient(future)
        .map_err(|error| QueryError::execution(format!("{label}: {error}")))?
        .map_err(|error| QueryError::execution(format!("{label}: {error}")))
}