-
sqlite is not working use tokio::sync::OnceCell;
const DB_URL: &str = "sqlite::memory:";
static POOL: OnceCell<Pool<Sqlite>> = OnceCell::const_new();
async fn get_global_db<'a>() -> &'a Pool<Sqlite> {
POOL.get_or_init(|| async {
SqlitePoolOptions::new()
.connect(DB_URL).await.unwrap()
}).await
}
async fn main() {
let mut request_receiver = bridge::get_request_receiver();
// It looks like the function is blocking here
get_global_db().await;
while let Some(request_unique) = request_receiver.recv().await {
crate::spawn(async {
let response_unique = handle_request(request_unique).await;
respond_to_dart(response_unique);
});
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 13 comments 3 replies
-
Yeah, it should possible to use |
Beta Was this translation helpful? Give feedback.
-
It is possible to use sqlite in memory, but not if you use files const DB_URL: &str = "sqlite:test.db"; |
Beta Was this translation helpful? Give feedback.
-
That's strange. It should just work as well as all other Rust crates. I'll take a look later when I have time :| |
Beta Was this translation helpful? Give feedback.
-
Hmm, this doesn't look like an issue with RIF. Could you try these and tell me if the problem persists?
P.S. File operations won't work if you run or build the app for the web. |
Beta Was this translation helpful? Give feedback.
-
The above two methods can automatically create sqlite files in rust binary programs, but flutter can not, I'm not sure if trying rust in flutter can we manipulate files directly in rust code (native)? |
Beta Was this translation helpful? Give feedback.
-
If I understood correctly, that those two methods can automatically create sqlite files in 'Application folder', is this right? Or is it that Could you provide some more information like...:
|
Beta Was this translation helpful? Give feedback.
-
I'm developing on macos (m1 chip), targeting the iphone emulator, and I don't see task error messages from the cli, except that each request fails after a timeout |
Beta Was this translation helpful? Give feedback.
-
I see 🤔 do you mind showing me your code, perhaps by sharing your repository address? One of the reasons could be the app sandbox policy of iOS. Can you try running your app on macOS and share the result? |
Beta Was this translation helpful? Give feedback.
-
you can look at this repo https://github.com/hoslo/tally |
Beta Was this translation helpful? Give feedback.
-
Sorry to say this, but I might be busy for a while, so if you happen to find a solution, please share the idea here or in a new pull request. If I become free again, I will dive into this soon. Thank you for your patience :) |
Beta Was this translation helpful? Give feedback.
-
It does work on Windows, other platforms coming soon |
Beta Was this translation helpful? Give feedback.
-
It also runs well on macOS |
Beta Was this translation helpful? Give feedback.
-
This was an interesting issue, though it wasn't related to RIF. Now I understand why it was not working on iOS. The Rust thread To understand what sandboxing is in iOS apps, take a look at this post: I was able to fix your app to make it work on iOS. Take a look at my fork: |
Beta Was this translation helpful? Give feedback.
This was an interesting issue, though it wasn't related to RIF.
Now I understand why it was not working on iOS. The Rust thread
panic
ked because you didn't have the permission to storetest.db
beside the executable binary. In iOS, you are only allowed to access specific folders of the app itself. Also, you didn't add?mode=wrc
to the end of the sqlite path to create one if not present.To understand what sandboxing is in iOS apps, take a look at this post:
I was able to fix your app to make it work on iOS. Take a look at my fork:
https://github.com/hoslo/tally/compare/m…