implement Debug for dexstring manually to show text when possible
This commit is contained in:
parent
0f87b75e8a
commit
b1e1c530ee
1 changed files with 29 additions and 2 deletions
|
|
@ -10,9 +10,36 @@ use pyo3::exceptions::PyTypeError;
|
||||||
use pyo3::prelude::*;
|
use pyo3::prelude::*;
|
||||||
|
|
||||||
#[pyclass]
|
#[pyclass]
|
||||||
#[derive(Clone, PartialEq, Eq, Debug, Ord, PartialOrd)]
|
#[derive(Clone, PartialEq, Eq, Ord, PartialOrd)]
|
||||||
pub struct DexString(pub androscalpel_serializer::StringDataItem);
|
pub struct DexString(pub androscalpel_serializer::StringDataItem);
|
||||||
|
|
||||||
|
impl std::fmt::Debug for DexString {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
|
||||||
|
if let Ok(string) = TryInto::<String>::try_into(self) {
|
||||||
|
f.write_str(&format!(
|
||||||
|
"DexString({}, {:#x})",
|
||||||
|
string, self.0.utf16_size.0
|
||||||
|
))
|
||||||
|
/*
|
||||||
|
f.debug_tuple("DexString")
|
||||||
|
.field(&string)
|
||||||
|
.field(&self.0.utf16_size.0)
|
||||||
|
.finish()
|
||||||
|
*/
|
||||||
|
} else {
|
||||||
|
f.write_str(&format!(
|
||||||
|
"DexString({:?}, {:#x})",
|
||||||
|
self.0.data, self.0.utf16_size.0
|
||||||
|
))
|
||||||
|
/*f.debug_tuple("DexString")
|
||||||
|
.field(&self.0.data)
|
||||||
|
.field(&self.0.utf16_size.0)
|
||||||
|
.finish()
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Serialize for DexString {
|
impl Serialize for DexString {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
|
|
@ -41,7 +68,7 @@ enum SerdeDexString {
|
||||||
impl From<&DexString> for SerdeDexString {
|
impl From<&DexString> for SerdeDexString {
|
||||||
fn from(DexString(string): &DexString) -> Self {
|
fn from(DexString(string): &DexString) -> Self {
|
||||||
if let Ok(string) = string.try_into() {
|
if let Ok(string) = string.try_into() {
|
||||||
SerdeDexString::String(string)
|
SerdeDexString::String(string) // TODO: utf16_size is remove, is this ok?
|
||||||
} else {
|
} else {
|
||||||
let androscalpel_serializer::StringDataItem {
|
let androscalpel_serializer::StringDataItem {
|
||||||
data,
|
data,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue