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
|
use internals::error::EncodingError;
use internals::encoder::{EncodableInHeader, EncodingWriter};
//FEATURE_TODO(fws_controll): allow controlling the amount of WS and if a CRLF should be used in FWS
// this is also usefull for parsing and keeping information about FWS structure
//FEATURE_TODO(cfws_with_comments): allow encoding commnets in CFWS
// this allows encoding comments in CFWS, combine with (part of?) fws_controll
// required (partially) for parsing comments (through skipping them works without this)
//
//pub enum WS {
// TAB,
// SPACE
//}
//
//pub struct FWS(pub Option<WithCRLF>, pub Vec1<WS> );
//
//pub struct WithCRLF {
// pub trailing: Vec<WS>
//}
#[derive(Debug, Hash, Clone, Eq, PartialEq)]
pub struct FWS;
//NOTE(IMPORTANT): when implementing this I have to assure that encoding CFWS followed by FWS works
// mainly after using a CR-LF-WSP seq you CAN NOT have another FWS which uses unsolds to a CR-LF-WSP
// currently we only remember the last FWS and do only make it in a CR-LF-SPACE sequence when we
// need to, so no problem here for now.
#[derive(Debug, Clone, Hash, Eq, PartialEq)]
pub enum CFWS {
//WithComment( Vec1<(Option<FWS>, Comment)>, Option<FWS> ),
SingleFws( FWS )
}
impl EncodableInHeader for CFWS {
fn encode(&self, handle: &mut EncodingWriter) -> Result<(), EncodingError> {
match *self {
CFWS::SingleFws(ref _fws ) => {
handle.write_fws();
}
}
Ok( () )
}
fn boxed_clone(&self) -> Box<EncodableInHeader> {
Box::new(self.clone())
}
}
#[cfg(test)]
mod test {
use super::*;
ec_test!{ simple_encode,
{
CFWS::SingleFws( FWS )
} => utf8 => [
MarkFWS,
Text " "
]
}
}
|