Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

async paramters error #909

Open
zhuchuanjing opened this issue Feb 11, 2025 · 1 comment
Open

async paramters error #909

zhuchuanjing opened this issue Feb 11, 2025 · 1 comment

Comments

@zhuchuanjing
Copy link

pub async fn asyn_call(&self, name: &str, func: &str, obj: Value) -> Result<Value> {
    let vm = self.vm_with_unit(name)?;
    Ok(vm.send_execute([func], (obj)).unwrap().async_complete().await.into_result()?)
}

this async function can't be compiled,
the error is "rustc: NonNull<rune::runtime::shared::SharedBox<AnyObj>> cannot be sent between threads safely
within rune::Value, the trait Send is not implemented for NonNull<rune::runtime::shared::SharedBox<AnyObj>>, which is required by rune::Value: Send"

@zhuchuanjing
Copy link
Author

change to
#[rune::function]
async fn call_async(name: &str, func: &str, obj: Value) -> Result {
let mut vm = RUNE.clone().vm_with_unit(name)?;
Ok(vm.async_call([func], (obj,)).await?)
}
get error "rustc: the trait bound for<'a, 'b> fn(&'a str, &'b str, rune::Value) -> impl std::future::Future<Output = std::result::Result<rune::Value, anyhow::Error>> {__rune_fn__call_async}: rune::module::Function<_, _> is not satisfied
the trait rune::module::Function<_, _> is not implemented for fn item fn(&str, &str, Value) -> impl Future<Output = Result<Value, Error>> {__rune_fn__call_async}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant