forked from mirrors/gecko-dev
This patch provides functions to extract the fragment directive from a url / a hash into an array of `TextDirective`s as well as to create a fragment directive string from given text directives. The algorithms are implemented as a rust crate. Interface functions and data structures which are accessible from C++ are provided in `lib.rs`. The actual implementation (using pure rust types) lives in `fragment_directive_impl.rs`, tests live in `test.rs`. The implementation currently only supports text directives. Other future directive types are not considered and will be ignored. The main function, `parse_fragment_directive()` takes a url / a url hash as parameter and returns (as out parameter) a struct which contains the stripped input url, the fragment directive string, and an array of parsed text directive objects. Additionally, there are functions that create a full fragment directive string from a list of text directives as well as a function that creates a single text directive string from a text directive. The `TextDirective` class, which is shared with C++, contains four string elements for the prefix, start, end and suffix elements. These strings are percent-decoded and do not contain identifiers (like the `-` that indicates it being a prefix or suffix). All elements besides `start` can be empty. The implemented algorithms are used in the following patches. Differential Revision: https://phabricator.services.mozilla.com/D195685 |
||
|---|---|---|
| .. | ||
| Cargo.toml | ||
| lib.rs | ||