-
Hi, pardon my ignorance as I am new to ffigen and Rust. Essentially, I found this library as I was searching for a way to use Huggingface's tokenizers library in my Flutter app. I have gotten most of it set up, and I do get an output when I call the API's function that downloads the tokenizer first before using it locally. However, I would like my app to work without a network connection, hence I would like to be able to use another one of the API's functions that accepts file paths to the tokenizer and loads it locally. I have tried copying the files to $crate/src, as well as to the However, referencing the path (relative or absolute) yields: I did a recursive search on the current working directory in Rust using Is it therefore possible to reference a local file through Rust? If not directly then maybe by changing the cwd? I was also thinking of reading the byte data in Flutter and sending that to my Rust function to write it to a file in its cwd. Edit: I just tried updating the Cargo.toml file to include my assets folder as such:
After running
However the same error persists when I try loading the file: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
At least for android, if I remember correctly, the "asset" files are not really a real file in disk but somehow part inside the apk file. Method 1: https://stackoverflow.com/questions/27140634/how-to-embed-resources-in-rust-executable Then the model is within your Method 2: Let Flutter manage it. Look at flutter doc to see how to manage an "asset". You may need a few lines of flutter code to copy the asset to, say, temporary folder, before rust can see it. |
Beta Was this translation helpful? Give feedback.
At least for android, if I remember correctly, the "asset" files are not really a real file in disk but somehow part inside the apk file.
Method 1: https://stackoverflow.com/questions/27140634/how-to-embed-resources-in-rust-executable Then the model is within your
.so
and you can use it like a u8 array.Method 2: Let Flutter manage it. Look at flutter doc to see how to manage an "asset". You may need a few lines of flutter code to copy the asset to, say, temporary folder, before rust can see it.