Skip to main content

ender/
facade.rs

1//! Contains some fake functions for encryption/decryption, compression/decompression
2//! to test the derive macros.
3
4/// In case that was not made clear: the functions in this module are fake!<br>
5/// They are just here to allow testing the derive macros in the playground.
6pub mod fake {
7    pub mod rsa {
8        use crate::{Read, Write};
9
10        use crate::{Decode, Encode, Encoder, EncodingResult};
11
12        pub fn encode<V: Encode<T>, T: Write>(
13            _value: V,
14            _encoder: &mut Encoder<T>,
15            _public_key: &[u8],
16            _private_key: &[u8],
17        ) -> EncodingResult<()> {
18            // Rsa encryption code here
19            unimplemented!()
20        }
21
22        pub fn decode<V: Decode<T>, T: Read>(
23            _decoder: &mut Encoder<T>,
24            _public_key: &[u8],
25            _private_key: &[u8],
26        ) -> EncodingResult<V> {
27            // Rsa decryption code here
28            unimplemented!()
29        }
30    }
31
32    pub mod aes {
33        use crate::{Read, Write};
34
35        use crate::{Encoder, EncodingResult};
36
37        pub fn encode<Orig, F>(
38            _encoder: &mut Encoder<Orig>,
39            _fun: F,
40            _iv: &[u8],
41            _key: &[u8],
42        ) -> EncodingResult<()>
43        where
44            Orig: Write,
45            F: FnOnce(&mut Encoder<Orig>) -> EncodingResult<()>,
46        {
47            // Aes encryption code here
48            unimplemented!()
49        }
50
51        pub fn decode<Orig, Val, F>(
52            _encoder: &mut Encoder<Orig>,
53            _fun: F,
54            _iv: &[u8],
55            _key: &[u8],
56        ) -> EncodingResult<Val>
57        where
58            Orig: Read,
59            F: FnOnce(&mut Encoder<Orig>) -> EncodingResult<Val>,
60        {
61            // Aes decryption code here
62            unimplemented!()
63        }
64    }
65
66    pub mod zlib {
67        pub use super::gzip::*;
68    }
69
70    pub mod gzip {
71        use crate::{Read, Write};
72
73        use crate::{Encoder, EncodingResult};
74
75        pub fn encode<Orig, F>(
76            _encoder: &mut Encoder<Orig>,
77            _fun: F,
78            _compression_level: u32,
79        ) -> EncodingResult<()>
80        where
81            Orig: Write,
82            F: FnOnce(&mut Encoder<Orig>) -> EncodingResult<()>,
83        {
84            // Compression code here
85            unimplemented!()
86        }
87
88        pub fn decode<Orig, Val, F>(
89            _encoder: &mut Encoder<Orig>,
90            _fun: F,
91            _compression_level: u32,
92        ) -> EncodingResult<Val>
93        where
94            Orig: Read,
95            F: FnOnce(&mut Encoder<Orig>) -> EncodingResult<Val>,
96        {
97            // Decompression code here
98            unimplemented!()
99        }
100    }
101}