PRECIS Framework: Preparation, Enforcement, and Comparison of Internationalized Strings in Application Protocols as described in rfc8264
This workspace implements the next crates:
This crate contains all the tools and parsers to generate PRECIS
tables from the Unicode Character Database UCD
.
This crate is only used to generate code required by
precis-core and
precis-profiles crates.
It contains the main dependencies in order to download UCD
files,
parse them and generate Rust code.
The core library of the PRECIS Framework. The base string classes IdentifierClass
and FreeFormClass
are implemented here as defined in
rfc8264.
This crate provides the APIs
required for profiles to be implemented.
You mostly won't require this crate unless you are implementing a new profile.
This crate implements the next PRECIS profiles:
- rfc8265. Preparation, Enforcement, and Comparison of Internationalized Strings Representing Usernames and Passwords.
- rfc8266. Preparation, Enforcement, and Comparison of Internationalized Strings Representing Nicknames
PRECIS profiles provides an API that allows application to prepare, enforce and compare internationalized strings.
// create OpaqueString profile
let profile = OpaqueString::new();
// prepare string
assert_eq!(profile.prepare("I'm Guybrush Threepwood, Mighty Pirate ☠"),
Ok(Cow::from("I'm Guybrush Threepwood, Mighty Pirate ☠")));
// enforce string
assert_eq!(profile.enforce("Look behind you, a three-headed monkey!🐒"),
Ok(Cow::from("Look behind you, a three-headed monkey!🐒")));
// compare strings
assert_eq!(profile.compare("That’s the second biggest 🐵 I’ve ever seen!",
"That’s the second biggest 🐵 I’ve ever seen!"), Ok(true));
If you find yourself continuously creating and destroying profiles to perform
any of the operation described for internationalized strings. You can make use
of the PrecisFastInvocation
trait.
Profiles implementing this trait will allow you to prepare, enforce or compare
internationalized strings without having to instantiate a specific profile.
Profiles usually use a static instance allocated with
lazy_static
assert_eq!(Nickname::prepare("Guybrush Threepwood"),
Ok(Cow::from("Guybrush Threepwood")));
assert_eq!(Nickname::enforce(" Guybrush Threepwood "),
Ok(Cow::from("Guybrush Threepwood")));
assert_eq!(Nickname::compare("Guybrush Threepwood ",
"guybrush threepwood"), Ok(true));
- networking - Enables crates to download Unicode Character Database
UCD
files from the network. This is helpful for developing and testing new Unicode releases, but this feature can not be enabled to generate the library documentation when the crate is uploaded tocrates.io
. For security reasons, network access is not allowed to crates to avoid compromising the security of docs.rs itself.
PRECIS recommends using toLowerCase
() operation as defined in the Unicode Standard
Unicode. This implementation uses the
one provided by Rust standard library
to_lowercase
.
This operation performs an unconditional mapping without tailoring. That is, the
conversion is independent of context and language.
Patches and feedback are welcome.
If you find this project helpful, you may consider making a donation:
This project is licensed under either of