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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
extern crate wdg_converter;

use wdg_converter::{CCPP,CL,CS,C8CP,C8L};

pub static ALPHABET32_ENCODE:&'static[u8;32]=&[
    065,066,067,068,069,070,071,072,
    073,074,075,076,077,078,079,080,
    081,082,083,084,085,086,087,088,
    089,090,050,051,052,053,054,055
];

pub static ALPHABET32_DECODE:&'static[u8;256]=&[
    255,255,255,255,255,255,255,255,
    255,255,255,255,255,255,255,255,
    255,255,255,255,255,255,255,255,
    255,255,255,255,255,255,255,255,
    255,255,255,255,255,255,255,255,
    255,255,255,255,255,255,255,255,
    255,255,026,027,028,029,030,031,
    255,255,255,255,255,255,255,255,
    255,000,001,002,003,004,005,006,
    007,008,009,010,011,012,013,014,
    015,016,017,018,019,020,021,022,
    023,024,025,255,255,255,255,255,
    255,255,255,255,255,255,255,255,
    255,255,255,255,255,255,255,255,
    255,255,255,255,255,255,255,255,
    255,255,255,255,255,255,255,255,
    255,255,255,255,255,255,255,255,
    255,255,255,255,255,255,255,255,
    255,255,255,255,255,255,255,255,
    255,255,255,255,255,255,255,255,
    255,255,255,255,255,255,255,255,
    255,255,255,255,255,255,255,255,
    255,255,255,255,255,255,255,255,
    255,255,255,255,255,255,255,255,
    255,255,255,255,255,255,255,255,
    255,255,255,255,255,255,255,255,
    255,255,255,255,255,255,255,255,
    255,255,255,255,255,255,255,255,
    255,255,255,255,255,255,255,255,
    255,255,255,255,255,255,255,255,
    255,255,255,255,255,255,255,255,
    255,255,255,255,255,255,255,255
];

pub struct B32<T>(T);

pub trait B32Encode<I,O>{
    fn encode(data:I)->O;
}

pub trait B32Decode<I,O>{
    fn validation(data:I)->B32DecodeError;
    fn decode(data:I)->Result<O,B32DecodeError>;
    unsafe fn unsafe_decode(data:I)->O;
}

#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum B32DecodeError{
    Null,
    InvalidByte,
    InvalidPadding,
    InvalidLength
}


include!("include/encode/encode.rs");
include!("include/decode/decode.rs");
include!("include/validation/validation.rs");

include!("./include/types/string.rs");
include!("./include/types/u8.rs");
include!("./include/types/i8.rs");
include!("./include/types/u16.rs");
include!("./include/types/i16.rs");
include!("./include/types/u32.rs");
include!("./include/types/i32.rs");
include!("./include/types/u64.rs");
include!("./include/types/i64.rs");
include!("./include/types/vec_u8.rs");
include!("./include/types/vec_u16.rs");
include!("./include/types/vec_u32.rs");
include!("./include/types/vec_u64.rs");
include!("./include/types/vec_i8.rs");
include!("./include/types/vec_i16.rs");
include!("./include/types/vec_i32.rs");
include!("./include/types/vec_i64.rs");