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
use core::fmt::Debug;
use kwap_common::Array;
use kwap_msg::{Opt, OptNumber};
#[cfg(feature = "alloc")]
use std_alloc::vec::Vec;
use crate::core::event::Event;
#[cfg(feature = "alloc")]
#[derive(Debug, Clone, Copy)]
pub struct Alloc;
#[cfg(feature = "alloc")]
impl Config for Alloc {
type PayloadBuffer = Vec<u8>;
type OptBytes = Vec<u8>;
type Opts = Vec<Opt<Vec<u8>>>;
type OptNumbers = Vec<(OptNumber, Opt<Vec<u8>>)>;
type Events = Vec<Event<Self>>;
}
pub trait Config: Sized + 'static + core::fmt::Debug {
type PayloadBuffer: Array<Item = u8> + Clone + Debug;
type OptBytes: Array<Item = u8> + 'static + Clone + Debug;
type Opts: Array<Item = Opt<Self::OptBytes>> + Clone + Debug;
type OptNumbers: Array<Item = (OptNumber, Opt<Self::OptBytes>)> + Clone + Debug;
type Events: Array<Item = Event<Self>>;
}
pub type Message<Cfg> =
kwap_msg::Message<<Cfg as Config>::PayloadBuffer, <Cfg as Config>::OptBytes, <Cfg as Config>::Opts>;