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

Calling a rust move closure from dyon script #747

Open
obsoleszenz opened this issue Mar 3, 2024 · 1 comment
Open

Calling a rust move closure from dyon script #747

obsoleszenz opened this issue Mar 3, 2024 · 1 comment

Comments

@obsoleszenz
Copy link

obsoleszenz commented Mar 3, 2024

Hey :)
I'm trying to call a move || closure from dyon, but that doesn't work. Also I wasn't able to figure out how to do something similar with the current library. Maybe someone has an idea?

    pub fn execute<'b>(&mut self, send_dsp_parameter: &dyn FnMut(String, f32) -> ()) {
        let mut module = Module::new();

        module.add_str(
            "set_dsp_parameter",
            move |rt: &mut dyon::Runtime| -> Result<(), String> {
                let value: f64 = rt.pop()?;
                let key: String = rt.pop()?;
                println!("{key} {value}");
                set_dsp_parameter(key, value);
                Ok(())
            },
            Dfn::nl(vec![Type::Str, Type::F64], Type::Void),
        );
        self.runtime
            .run(&mut Arc::new(module))
            .expect("Failed running");
    }
@bvssvni
Copy link
Member

bvssvni commented Mar 4, 2024

Do you have a compile time error?

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

2 participants