oauth1_client/
percent_encoding.rs1use rfc3986::{percent_decode_str, utf8_percent_encode, AsciiSet, NON_ALPHANUMERIC};
5
6pub const RESERVED_CHARACTERS: &AsciiSet = &NON_ALPHANUMERIC
8 .remove(b'-')
9 .remove(b'.')
10 .remove(b'_')
11 .remove(b'~');
12
13pub fn encode_string(input: &str) -> String {
15 utf8_percent_encode(input, RESERVED_CHARACTERS).to_string()
16}
17
18pub fn decode_string(input: &str) -> Result<String, Box<dyn std::error::Error>> {
20 Ok(percent_decode_str(input)?.decode_utf8()?.to_string())
21}