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
use crate::pod::Bytes;
#[allow(unused)]
#[inline]
pub(crate) fn align(offset: usize, size: usize) -> usize {
(offset + (size - 1)) & !(size - 1)
}
#[derive(Debug, Default, Clone, Copy)]
pub struct StringTable<'data> {
data: Bytes<'data>,
}
impl<'data> StringTable<'data> {
pub fn new(data: Bytes<'data>) -> Self {
StringTable { data }
}
pub fn get(&self, offset: u32) -> Result<&'data [u8], ()> {
self.data.read_string_at(offset as usize)
}
}