New crates - unic-langid and unic-locale - Request For Review/Feedback

Hi all,

I carved out from fluent-locale-rs two crates that I hope will one day become part of UNIC (Rust implementation of ICU-like API set).

The first crate is called unic-langid and handles parsing/manipulating and serializing of Unicode Language Identifiers (think en-US or zh-Hans-HK).

The second is called unic-locale and extends on top of unic-langid adding handling of Unicode Extensions (think en-US-u-hc-h24 or pl-ca-buddhist-x-private).

Both implement Unicode TS #35 Language and Locale Identifiers

The reason I separated them is that fairly often people only want to support the former in their code, before they realize that they need the latter. By separating those two crates I allow them to use the simpler and cheaper form, and easily switch to a more complete one.

I think it's a great level of detail for anyone to contribute to. The crates are small, self-contained, and the spec is quite clear and well written.
I'm at the point when the crates don't really plug into any CLDR data for validity information (think, Territory etc.) or locale specific data (addLikelySubtags is not there, nor is RTL data).

But before we add that, I'd like to make sure that the code is well written and data structures and traits are properly designed for Rust. If we succeed, this kind of crate will be at the core of any and all intl/l10n using code so I believe it's worth putting effort into making the code really neat because once all higher level APIs start using it (think, all internationalizaton crates, GUI and localization APIs), it'll be hard to break compatibility.

I'd like to ask all performance, memory and API design experts to take a look and help me get things right - should we use traits? Should Locale inherit from LanguageIdentifier? Are the structs reasonable? What about smallstring or istring or tinystr instead of String? What about return types? How to mark that a struct is well formed, but invalid?

If you have particular code related issues or ideas, file them in the repo. If you want to discuss the crates as how they fit into UNIC see this issue. For higher-level APIs discussion, see this issue.

If you have time to help me, I'd really appreciate community's input!

Thanks!
zb.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.