Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

How to use ThreadsafeFunction in an object/struct #2597

noahbald started this conversation in General
Discussion options

Hello, I'm struggling to figure out how I can use a threadsafe-function in a struct.
As an object I get the following error

#[napi(object)]
#[derive(Clone, derive_more::Debug)]
pub struct Generator {
    #[debug(skip)]
    // the trait bound `Arc<ThreadsafeFunction<String, String>>: ToNapiValue` is not satisfied
    pub callback:
        Arc<napi::threadsafe_function::ThreadsafeFunction<String, String>>,
}

Or as a class

// the trait bound `&mut Arc<ThreadsafeFunction<String, String>>: ToNapiValue` is not satisfied
#[napi]
#[derive(Clone, derive_more::Debug)]
pub struct Generator {
    #[debug(skip)]
    pub callback:
        Arc<napi::threadsafe_function::ThreadsafeFunction<String, String>>,
}
You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant
Morty Proxy This is a proxified and sanitized view of the page, visit original site.