pct_str/error.rs
1/// Encoding error.
2///
3/// Raised when a given input string is not percent-encoded as expected.
4#[derive(Debug, Clone, thiserror::Error)]
5#[error("invalid percent-encoded string")]
6pub struct InvalidPctString<T>(pub T);
7
8impl<T> InvalidPctString<T> {
9 pub fn map<U>(self, f: impl FnOnce(T) -> U) -> InvalidPctString<U> {
10 InvalidPctString(f(self.0))
11 }
12}
13
14impl<T: ?Sized + ToOwned> InvalidPctString<&T> {
15 pub fn into_owned(self) -> InvalidPctString<T::Owned> {
16 self.map(T::to_owned)
17 }
18}