1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
mod urlcode;
pub use urlcode::*;
mod decode;
mod encode;
pub mod rand;
pub use decode::*;
pub use encode::{Encode, EncodeFrom, EncodeResult};
pub const ORIGIN_KEY: &'static str =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,.?!:;+-*/^@0123456789%<>#$&=_|()";
pub fn is_all_ascii(s: &str) -> bool {
!s.chars().any(|c| c.len_utf8() != 1)
}
#[derive(Debug, PartialEq, Eq)]
pub struct DecodeError(String);
impl Into<String> for DecodeError {
fn into(self) -> String {
self.0
}
}
pub trait EncodeTrait<T> {
fn encode(_: T) -> String;
}
pub trait DecodeTrait<T> {
fn decode(_: T) -> Result<String, DecodeError>;
}