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

C + Go Bindings #11

Open
ghost opened this issue Feb 12, 2018 · 11 comments
Open

C + Go Bindings #11

ghost opened this issue Feb 12, 2018 · 11 comments
Labels
Priority: High Everyone cares Type: Enhancement New feature or request

Comments

@ghost
Copy link

ghost commented Feb 12, 2018

seems its quite easy
https://github.com/medimatrix/rust-plus-golang

Would be interesting to try at some stage..

@quadrupleslap quadrupleslap changed the title using with golang C + Go Bindings Feb 13, 2018
@quadrupleslap
Copy link
Owner

quadrupleslap commented Feb 13, 2018

Yeah, that would be pretty cool! But I'd like to implement the URL overrides first, just to get the entire API down - I think that's the only thing preventing this from being fully usable (at least, without shipping an entire web server, too).

@quadrupleslap quadrupleslap added the Type: Enhancement New feature or request label Feb 13, 2018
@ghost
Copy link
Author

ghost commented Feb 15, 2018

Sounds like a plan :)

I have been looking into the area of Signing and Packaging for Windows store. Will raise an issue to discuss now.

@ghost
Copy link
Author

ghost commented Feb 22, 2018

I have not had a chance to work on this yet.
It's definitely on my to-do list though.

If you come a Ross any ideas or examples do post here and I will try them out

@ghost
Copy link
Author

ghost commented Feb 26, 2018

I have an idea to try.

PWA is now actually useable because Service Workers and Web workers is pretty stable and used.
So if a developer can supply to the Rust system a stat URL, they dont need to write any Rust or golang etc.
For things like Printing, Dialogs it could be done by ether providing a JS API to acceyy them and so a developer just needs to call the API.

I know this is a bit radical and different.. Happy to help and discuss though.

@quadrupleslap
Copy link
Owner

quadrupleslap commented Feb 27, 2018

That's a great idea, but isn't that exactly what Cordova does? It's mostly mobile-centric, though.

Edit: I guess Cordova's centered around static files, not URLs, though. It's quite a bit different, now that I think about it.

@ghost
Copy link
Author

ghost commented Feb 27, 2018

yes i think your right - good point... I used it once for a bit. It worked but very clunky.

I guess the difference is this.
Today with PWA and Service worker you dont need so many hooks into the app running in a browser because its pretty self contained now thanks. SO you basically only need a service worker to kick it off.
I guess thats my point. Its true i am playing around with ideas. Its more a hunch..

@quadrupleslap quadrupleslap added the Priority: High Everyone cares label Mar 16, 2018
@ghost
Copy link
Author

ghost commented Mar 24, 2018

Has the code moved on further that you think this might be possible ?
Hate to be pushy but I am a golang programmer and don't have enough rust experience to really tell from the existing code.

Thinking about it, all I need is to be able to boot it up giving it a localhost URL to run from. Or maybe a file system path to inject the JS code from.

All my front end is coded up in golang and transpired to JS.

@quadrupleslap
Copy link
Owner

quadrupleslap commented Mar 26, 2018

If that's all you need, this snippet can do it.

extern crate tether;

fn main() {
    tether::builder()
        .html("<meta http-equiv=\"refresh\" content=\"0;URL='{{ YOUR URL }}'\" />")
        .start();
}

Feel free to ask for more advice/code! Yeah, the core API is definitely stable, but I'm kind of busy right now. I'd need to do the following things to get a full Go interface:

  • Write C bindings, because Go and Rust can only reliably communicate through C.
  • Write idiomatic Go bindings (help translating the Rust interface appreciated).
  • Make builds of the staticlib on GitLab, because otherwise C/Go users would still need to install the Rust toolchain.

Is the Rust code above enough that I can move this to low priority, or are Go bindings still necessary for you?

@ghost
Copy link
Author

ghost commented Mar 26, 2018 via email

@quadrupleslap
Copy link
Owner

Yeah, Rust needs to be installed, unless this issue is completed.

@ghost
Copy link
Author

ghost commented Mar 26, 2018

ok thanks. For now, i think i can write the rust code to kick off the PWA.

I plan to boot it off localhost, which is a GRPC server.
So the rust code and the golang code have no link and run in their own App Domains. Just Http between them at runtime.

If you even do get a golang wrapper, then i can link to the Tether code from golang.
I can run the HTTP server on a goroutine and the GUI on a different routine.
This will eliminate the 2 Application Domains situation and have a single App Domain.
But i can still use HTTP between them.

For Mobile, if this gets that far you can do the same sort of approach using gomobile.
Your linking the golang code to the man Application Activity.
The App Activity then starts the WebView ( Tether) and the golang server on a different thread.
I dont think i can use HTTP between them though.

SO, once you get through that you start askng yourself if its possible to not using http between them but just API binary calls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: High Everyone cares Type: Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant