Crate dev_bestia_url_utf8[][src]

Expand description

dev_bestia_url_utf8

Library for url utf8 encode/decode
repository; version: 0.1.28 date: 2021-10-22 authors: Luciano Bestia

Lines in Rust code Lines in Doc comments Lines in Comments Lines in examples Lines in tests

Motivation

Urls must be constantly encoded and decoded.
It deserves something short like the macro url!("x/y/{}", name).
This module is strictly limited to utf8 urls.
Url is made of parts, fragments or segments mostly delimited by slash “/”.
They must be separately encoded/decoded, not as a whole url string.
It is impossible to guarantee that the whole string is correctly encoded/decoded.
But is possible to minimize the misuse of the String type for Url.
With the normal String it is not possible to force the developer to encode/decode.
With special wrapper types around String is possible to help the coder to write properly and not forget about it.
TODO: analyze if is possible to use more &str and Cow instead of always allocating String.
But urls are usually small and this is not a priority.

Development

I use cargo-auto for my automation tasks like cargo auto build or cargo auto doc, …

cargo crev reviews and advisory

We live in times of danger with supply chain attacks.
It is recommended to always use cargo-crev
to verify the trustworthiness of each of your dependencies.
Please, spread this info.
You can also read reviews quickly on the web:
https://web.crev.dev/rust-reviews/crates/

open-source free and free as a beer

My open-source projects are free and free as a beer (MIT license).
I just love programming.
But I need also to drink. If you find my projects and tutorials helpful,
please buy me a beer donating on my paypal.
You know the price of a beer in your local bar ;-)
So I can drink a free beer for your health :-)
Na zdravje! Alla salute! Prost! Nazdravlje! 🍻

Macros

Constructor macro for UrlUtf8EncodedString

Structs

the url must be utf 8. Only the 5 control characters are encoded.
url has parts or fragments or segments delimited mostly by slash /
every part must be encoded/decoded separately,
to maintain the control character slash /

Type UrlUtf8EncodedString explicitly informs that the content has been url encoded.
It contains a string with the whole url.
The url is constructed with a special macro, where the dynamic parts are always encoded.
It is impossible to force the developer to properly encode the static part of the url.
But this special type is making this kind of errors difficult, obvious and traceable.

Enums

thiserror enum