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

Higher-level and more safe API #10

Open
0nkery opened this issue Nov 19, 2018 · 2 comments
Open

Higher-level and more safe API #10

0nkery opened this issue Nov 19, 2018 · 2 comments

Comments

@0nkery
Copy link

0nkery commented Nov 19, 2018

Hi!

Thanks for helpful library!

Are there any plans to implement more higher-level and safe API?
I have kind of proposal but there are many details it lacks.

  1. Plugin trait which defines all the callbacks user should implement
    in two ways: low-level (raw) and high-level. The latter operates on more idiomatic
    Rust entities such as references, Rust structs, strings and numeric values
    while the former leaves all the raw details in place allowing to skip possibly
    slow conversions and defaults to calling 'high-level' methods.
  2. One more macros which defines extern "C" functions along with static
    declaration of user object which implements Plugin trait. Functions just deal
    with acquisition of static object and call methods on it.
  3. init callback can be more elaborate - it can initialize callbacks to Janus Core
    which crate then will use to provide more high-level API for them (just regular public functions, no need to fetch
    global PluginCallbacks object and call functions there).

It's unclear to me how to wrap all Janus objects from outside in more convenient
and safe way.

What do you think of this?

@mqp
Copy link
Collaborator

mqp commented Aug 21, 2019

It's fair to say it's also unclear to me. The current code, as you can see, defaults to a pretty low amount of wrapping (e.g. sending through *c_char instead of str) because performance and detail-orientedness in plugins seems important and I didn't want to make any assumptions. I also definitely agree that there is a lot of room to make it easier for plugins to define the functions and deal with the callbacks provided in init. If there were a way to provide both a low-level and high-level API in the way you suggested without duplicating a lot of code or introducing performance problems, I would be very interested.

@manifest
Copy link

Marshall, thank you for the answer. That's nice to see the project is still under maintenance. We'll take another look and come with some suggestions on the plugin API if that's ok.

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

3 participants