Struct Strings
pub struct Strings<'a> { /* private fields */ }Expand description
‘#Strings’ hold various identifiers which are referenced form other tables within the CIL metadata. e.g. various strings for reflection: function names, 0xclass names, 0xvariables, 0x…
The Strings object provides helper methods to access the data within this blob, 0xand parse / process it
properly according to the standard.
§Examples
use dotscope::metadata::streams::Strings;
let data = &[0u8, b'H', b'e', b'l', b'l', b'o', 0u8];
let strings = Strings::from(data).unwrap();
let s = strings.get(1).unwrap();
assert_eq!(s, "Hello");§Reference
Implementations§
§impl<'a> Strings<'a>
impl<'a> Strings<'a>
pub fn get(&self, index: usize) -> Result<&'a str>
pub fn get(&self, index: usize) -> Result<&'a str>
Get a view into the string contained at the provided location. This will process the heap information, and return a string slice which represents the object located there (if any)
§Arguments
- ‘index’ - The offset within the heap to be accessed (comes from metadata tables)
§Errors
Returns an error if the index is out of bounds or the string data is invalid UTF-8
pub fn iter(&self) -> StringsIterator<'_> ⓘ
pub fn iter(&self) -> StringsIterator<'_> ⓘ
Returns an iterator over all strings in the heap
Provides zero-copy sequential access to all null-terminated UTF-8 strings.
Each iteration yields a Result<(usize, &str)> with the offset and string content.
§Examples
use dotscope::metadata::streams::Strings;
let data = &[0u8, b'H', b'e', b'l', b'l', b'o', 0u8, b'W', b'o', b'r', b'l', b'd', 0u8];
let strings = Strings::from(data).unwrap();
for result in strings.iter() {
match result {
Ok((offset, string)) => println!("String at {}: '{}'", offset, string),
Err(e) => eprintln!("Error: {}", e),
}
}Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Strings<'a>
impl<'a> RefUnwindSafe for Strings<'a>
impl<'a> Send for Strings<'a>
impl<'a> Sync for Strings<'a>
impl<'a> Unpin for Strings<'a>
impl<'a> UnwindSafe for Strings<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more