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
89
90
91
92
93
94
#![no_std]
use core::fmt::Debug;
use core::marker::PhantomData;
#[cfg(feature = "alloc")]
extern crate alloc;
pub trait Stor<Inner: Debug = ()>: Debug {
type List: AsRef<[Inner]> + Debug;
type String: AsRef<str> + Debug;
type Bytes: AsRef<[u8]> + Debug;
}
#[cfg(feature = "alloc")]
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct Owned;
#[cfg(feature = "alloc")]
impl <T: Debug> Stor<T> for Owned {
type List = alloc::vec::Vec<T>;
type String = alloc::string::String;
type Bytes = alloc::vec::Vec<u8>;
}
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct Ref<'a> (PhantomData<&'a ()>);
impl <'a, T: Debug + 'a> Stor<T> for Ref<'a> {
type List = &'a [T];
type String = &'a str;
type Bytes = &'a [u8];
}
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct Const<const N: usize>;
impl <T: Debug, const N: usize> Stor<T> for Const<N> {
type List = [T; N];
type String = &'static str;
type Bytes = [u8; N];
}
#[cfg(feature = "heapless")]
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct Heapless<const N: usize>;
#[cfg(feature = "heapless")]
impl <T: Debug, const N: usize> Stor<T> for Heapless<N> {
type List = heapless::Vec<T, N>;
type String = heapless::String<N>;
type Bytes = heapless::Vec<u8, N>;
}
#[cfg(test)]
mod tests {
}