harn-vm 0.10.135

Async bytecode virtual machine for the Harn programming language
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//! Async-safe marker for model- or client-invoked Harn tool handlers.

use std::future::Future;
use std::pin::Pin;

tokio::task_local! {
    static INSIDE_TOOL_HANDLER: ();
}

pub(crate) fn scope<F: Future>(future: F) -> Pin<Box<impl Future<Output = F::Output>>> {
    Box::pin(INSIDE_TOOL_HANDLER.scope((), future))
}

pub(crate) fn is_active() -> bool {
    INSIDE_TOOL_HANDLER.try_with(|()| true).unwrap_or(false)
}