foundry-local-sdk 2.0.1

Local AI model inference powered by the Foundry Local Core engine
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//! Shared async helper for running blocking native calls.

use crate::error::{FoundryLocalError, Result};

/// Run a blocking native operation on the tokio blocking pool.
pub(crate) async fn spawn_blocking<T, F>(f: F) -> Result<T>
where
    F: FnOnce() -> Result<T> + Send + 'static,
    T: Send + 'static,
{
    tokio::task::spawn_blocking(f)
        .await
        .map_err(|e| FoundryLocalError::Internal {
            reason: format!("blocking task join error: {e}"),
        })?
}