Struct goblin::strtab::Strtab [−][src]
A common string table format which is indexed by byte offsets (and not
member index). Constructed using parse
with your choice of delimiter. Please be careful.
Implementations
impl<'a> Strtab<'a>
[src]
pub fn new(bytes: &'a [u8], delim: u8) -> Self
[src]
Construct a new strtab with bytes
as the backing string table, using delim
as the delimiter between entries
pub unsafe fn from_raw(ptr: *const u8, size: usize, delim: u8) -> Strtab<'a>
[src]
Construct a strtab from a ptr
, and a size
, using delim
as the delimiter
Safety
This function creates a Strtab
directly from a raw pointer and size
pub fn parse(
bytes: &'a [u8],
offset: usize,
len: usize,
delim: u8
) -> Result<Strtab<'a>>
[src]
bytes: &'a [u8],
offset: usize,
len: usize,
delim: u8
) -> Result<Strtab<'a>>
Parses a strtab from bytes
at offset
with len
size as the backing string table, using delim
as the delimiter
pub fn to_vec(&self) -> Result<Vec<&'a str>>
[src]
Converts the string table to a vector, with the original delim
used to separate the strings
pub fn get(&self, offset: usize) -> Option<Result<&'a str>>
[src]
Safely parses and gets a str reference from the backing bytes starting at byte offset
.
If the index is out of bounds, None
is returned.
Requires feature = "alloc"
pub fn get_unsafe(&self, offset: usize) -> Option<&'a str>
[src]
Gets a str reference from the backing bytes starting at byte offset
.
If the index is out of bounds, None
is returned. Panics if bytes are invalid UTF-8.
Trait Implementations
impl<'a> Debug for Strtab<'a>
[src]
impl<'a> Default for Strtab<'a>
[src]
impl<'a> Index<usize> for Strtab<'a>
[src]
Auto Trait Implementations
impl<'a> RefUnwindSafe for Strtab<'a>
impl<'a> Send for Strtab<'a>
impl<'a> Sync for Strtab<'a>
impl<'a> Unpin for Strtab<'a>
impl<'a> UnwindSafe for Strtab<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,