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

How to access database in rust flutter #17

Closed
kunjee17 opened this issue Dec 27, 2020 · 4 comments
Closed

How to access database in rust flutter #17

kunjee17 opened this issue Dec 27, 2020 · 4 comments

Comments

@kunjee17
Copy link

Rust has few libraries that allows database access like sqlite and also native storat. Is it possible to do it with rust and access rust function via flutter?

Basically I want push as much as on Rust side as I'm not that happy with flexibility of dart language.

BTW thanks for awesome template. :-)

@brickpop
Copy link
Owner

Thank you @kunjee17 :)

In principle there's nothing preventing you to accomplish this use case.
What you need to do is creating a library, importing the Rust dependencies of your choice and then expose your functions so that Dart can call them.

The part where you should pay most attention would be when passing parameters other than numbers, chars and booleans. Strings need conversion from/to UTF8 pointers and structs can theoretically be mapped on both sides, but I haven't tried them myself.

@kunjee17
Copy link
Author

Thanks for reply @brickpop . I was specifically asking if I need some native binding to access native api from Rust?

For example can I use libraries like sqlx, diesel with this approach or it is not possible?

@brickpop
Copy link
Owner

brickpop commented Dec 28, 2020

Oh, do you mean accessing still another external library from Rust?

In such case you'd need to also bundle the relevant libsqlite.so / libsqlite.a files (however they look) into the iOS/Android projects.
Then, you may need to tell Rust about the external library's signatures (bindgen) and finally call them

Hope it helps

@kunjee17
Copy link
Author

I guess yes. thanks for reply and nice library. I m closing this issue for now.

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