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
/// Result alias for storage operation
///
/// Error is a boxed container for generic error trait. Therefore any kind of errors can be
/// captured by storageresult.
pub type StorageResult<T> = ;
/// Triat for storage interaction
///
/// Rad can utilizes storage to save given input as modified form and extract data from
///
/// # Example
///
/// ```rust
/// use r4d::{RadStorage, RadError, StorageOutput, StorageResult};
///
/// pub struct StorageDemo {
/// content: Vec<String>,
/// }
///
/// impl RadStorage for StorageDemo {
/// fn update(&mut self, args: &[String]) -> StorageResult<()> {
/// if args.is_empty() {
/// return Err(Box::new(RadError::InvalidArgument("Not enough arguments".to_string())));
/// }
/// self.content.push(args[0].clone());
///
/// Ok(())
/// }
/// fn extract(&mut self, serialize: bool) -> StorageResult<Option<StorageOutput>> {
/// let result = if serialize {
/// StorageOutput::Binary(self.content.join(",").as_bytes().to_vec())
/// } else {
/// StorageOutput::Text(self.content.join(","))
/// };
/// Ok(Some(result))
/// }
/// }
/// ```
/// Output that storage creates