tether icon indicating copy to clipboard operation
tether copied to clipboard

C + Go Bindings

Open ghost opened this issue 7 years ago • 11 comments
trafficstars

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

Would be interesting to try at some stage..

ghost avatar Feb 12 '18 23:02 ghost

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 avatar Feb 13 '18 09:02 quadrupleslap

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 avatar Feb 15 '18 08:02 ghost

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 avatar Feb 22 '18 10:02 ghost

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.

ghost avatar Feb 26 '18 11:02 ghost

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.

quadrupleslap avatar Feb 27 '18 08:02 quadrupleslap

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..

ghost avatar Feb 27 '18 08:02 ghost

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.

ghost avatar Mar 24 '18 21:03 ghost

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?

quadrupleslap avatar Mar 26 '18 08:03 quadrupleslap

Would that's alot of golang code to write. I guess it will mean I need rust also installed ?

On Mon, Mar 26, 2018, 10:40 AM Ram [email protected] wrote:

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, because school. I'd need to do the following things to get a full Go interface (assuming you still think this is a worthwhile feature):

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

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/quadrupleslap/tether/issues/11#issuecomment-376089575, or mute the thread https://github.com/notifications/unsubscribe-auth/ATuCwggTR7DtaPsBFcN-bhyirgInThMrks5tiKmOgaJpZM4SDAZ2 .

ghost avatar Mar 26 '18 11:03 ghost

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

quadrupleslap avatar Mar 26 '18 12:03 quadrupleslap

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.

ghost avatar Mar 26 '18 15:03 ghost