coded_chars/
characters.rs

1//! This module provides control characters not sorted elsewhere....
2//!
3//! Complementary information in ISO 1745.
4
5pub mod separator {
6    /// Unit separator
7    pub const US: char = '\x1F';
8    
9    /// Record separator
10    pub const RS: char = '\x1E';
11    
12    /// Group separator
13    pub const GS: char = '\x1D';
14    
15    /// File separator
16    pub const FS: char = '\x1C';
17}
18
19/// # Null character
20/// 
21/// NUL is used for media-fill or time-fill. NUL characters may be inserted into, or removed from, a data
22/// stream without affecting the information content of that stream, but such action may affect the
23/// information layout and/or the control of equipment.
24pub const NUL:char = '\x00';
25
26/// # Bell
27/// 
28/// BEL is used when there is a need to call for attention; it may control alarm or attention devices.
29pub const BEL:char = '\x07';
30
31/// # Cancel
32/// 
33/// CAN is used to indicate that the data preceding it in the data stream is in error. As a result, this data
34/// shall be ignored. The specific meaning of this control function shall be defined for each application
35/// and/or between sender and recipient.
36pub const CAN:char = '\x18';
37
38/// # End of medium
39/// 
40/// EM is used to identify the physical end of a medium, or the end of the used portion of a medium, or the
41/// end of the wanted portion of data recorded on a medium.
42pub const EM:char = '\x19';
43
44/// # Substitute
45/// 
46/// SUB is used in the place of a character that has been found to be invalid or in error. SUB is intended to
47/// be introduced by automatic means.
48pub const SUB:char = '\x1A';
49
50/// Space
51pub const SPC:char = '\x20';
52
53/// Delete
54pub const DEL:char = '\x7f';
55
56
57#[cfg(test)]
58mod tests {
59    use super::*;
60
61    #[test]
62    fn test_separator_constants() {
63        assert_eq!(separator::US, '\x1F'); // Unit separator
64        assert_eq!(separator::RS, '\x1E'); // Record separator
65        assert_eq!(separator::GS, '\x1D'); // Group separator
66        assert_eq!(separator::FS, '\x1C'); // File separator
67    }
68
69    #[test]
70    fn test_control_characters() {
71        assert_eq!(NUL, '\x00'); // Null
72        assert_eq!(BEL, '\x07'); // Bell
73        assert_eq!(CAN, '\x18'); // Cancel
74        assert_eq!(EM, '\x19');  // End of medium
75        assert_eq!(SUB, '\x1A'); // Substitute
76        assert_eq!(SPC, '\x20'); // Space
77        assert_eq!(DEL, '\x7F'); // Delete
78    }
79}