-
Notifications
You must be signed in to change notification settings - Fork 18
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
Rust crate #158
base: main
Are you sure you want to change the base?
Rust crate #158
Conversation
Okay, I'm having second thoughts about this. The way that we're building up the data is "clever", and every time I do something "clever" I should stop and think if it's actually the right thing. Originally my plan was to store the data as data, ie. in the So now I'm thinking that just storing all the data as a big serialisable thing and deserialising it at runtime is cleaner. Don't know, will try it. |
FWIW, I hit a similar compilation times problem in https://github.com/madig/glyphsinfo-rs when I tried to include all the GlyphInfo.xml data as plain old data types to compile. Or maybe it was me trying to use enums where it made sense. I then settled on using https://crates.io/crates/postcard to include a binary dump of the data to deser at runtime 🤷♀️ |
I used Moving to deserialisation knocked 15% off the binary size of fontspector-wasm, so yeah, much better than building the data in code. |
Maybe using This doesn't solve the problem to the point of you being able to write everything in Rust source code instead of deserialising at runtime, but it's part of it I guess. I've not messed with prost types before but could they use |
Sadly not: Type::String => format!("{}::alloc::string::String", prost_path(self.config)), Anyway I think I'm pretty happy with where I've got to. |
Provides a Rust interface to the language data. Uses the data in the
Lib/gflanguages/data
directory, compiling it into Rust lazy-static structures at build time.