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
pub trait BitSetAware: Sized + Into<u16> + TryFrom<u16, Error=BitSetAwareTryFromU16Error> + ParseNumber + FromBytes<Error=ParseNumberError> + Copy + Clone + PartialEq + Eq + PartialOrd + Ord + Hash + Into<u32> + Into<u64> + Into<usize> + Into<i32> + Into<i64> + Into<isize>
{
const LinuxMaximum: u32;
const InclusiveMinimum: Self;
const InclusiveMaximum: Self;
#[doc(hidden)]
const Prefix: &'static [u8] = b"";
#[doc(hidden)]
const OneBasedCorrection: u16 = 0;
#[inline(always)]
fn into_bit_set(self) -> BitSet<Self>
{
let mut new = BitSet::empty();
new.add(self);
new
}
#[doc(hidden)]
#[inline(always)]
fn dehydrate(self) -> u16
{
let value: u16 = self.into();
value - Self::OneBasedCorrection
}
#[doc(hidden)]
#[inline(always)]
fn hydrate(value: u16) -> Self
{
Self::from_validated_u16(value + Self::OneBasedCorrection)
}
#[doc(hidden)]
fn from_validated_u16(value: u16) -> Self;
#[doc(hidden)]
#[inline(always)]
fn parse_file_name(file_name: &OsStr) -> io::Result<Option<Self>>
{
let file_name = file_name.as_bytes();
if !file_name.starts_with(Self::Prefix)
{
return Ok(None)
}
let bytes = &file_name[Self::Prefix.len() .. ];
let parsed_number = u16::parse_decimal_number(bytes).map_err(io_error_other)?;
Ok(Some(Self::try_from(parsed_number).map_err(io_error_other)?))
}
}