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
extern crate base64;
extern crate serde;
#[cfg(test)]
#[macro_use]
extern crate matches;
pub mod multibox;
pub mod multifeed;
pub mod multihash;
pub mod multikey;
pub(crate) fn split_at_byte(input: &[u8], byte: u8) -> Option<(&[u8], &[u8])> {
for i in 0..input.len() {
if unsafe { *input.get_unchecked(i) } == byte {
let (start, end) = input.split_at(i);
return Some((start, &end[1..]));
}
}
return None;
}
pub(crate) fn skip_prefix<'a>(input: &'a [u8], prefix: &[u8]) -> Option<&'a [u8]> {
if input.starts_with(prefix) {
Some(&input[prefix.len()..])
} else {
None
}
}