pub enum ProguardRecord<'s> {
    Header {
        key: &'s str,
        value: Option<&'s str>,
    },
    Class {
        original: &'s str,
        obfuscated: &'s str,
    },
    Field {
        ty: &'s str,
        original: &'s str,
        obfuscated: &'s str,
    },
    Method {
        ty: &'s str,
        original: &'s str,
        obfuscated: &'s str,
        arguments: &'s str,
        original_class: Option<&'s str>,
        line_mapping: Option<LineMapping>,
    },
}
Expand description

A Proguard Mapping Record.

Variants§

§

Header

A Proguard Header.

Fields

§key: &'s str

The Key of the Header.

§value: Option<&'s str>

Optional value if the Header is a KV pair.

§

Class

A Class Mapping.

Fields

§original: &'s str

Original name of the class.

§obfuscated: &'s str

Obfuscated name of the class.

§

Field

A Field Mapping.

Fields

§ty: &'s str

Type of the field

§original: &'s str

Original name of the field.

§obfuscated: &'s str

Obfuscated name of the field.

§

Method

A Method Mapping.

Fields

§ty: &'s str

Return Type of the method.

§original: &'s str

Original name of the method.

§obfuscated: &'s str

Obfuscated name of the method.

§arguments: &'s str

Arguments of the method as raw string.

§original_class: Option<&'s str>

Original class of a foreign inlined method.

§line_mapping: Option<LineMapping>

Optional line mapping of the method.

Implementations§

source§

impl<'s> ProguardRecord<'s>

source

pub fn try_parse(line: &'s [u8]) -> Result<Self, ParseError<'s>>

Parses a line from a proguard mapping file.

§Examples
use proguard::ProguardRecord;

// Headers
let parsed = ProguardRecord::try_parse(b"# compiler: R8");
assert_eq!(
    parsed,
    Ok(ProguardRecord::Header {
        key: "compiler",
        value: Some("R8")
    })
);

// Class Mappings
let parsed =
    ProguardRecord::try_parse(b"android.arch.core.executor.ArchTaskExecutor -> a.a.a.a.c:");
assert_eq!(
    parsed,
    Ok(ProguardRecord::Class {
        original: "android.arch.core.executor.ArchTaskExecutor",
        obfuscated: "a.a.a.a.c"
    })
);

// Field
let parsed = ProguardRecord::try_parse(
    b"    android.arch.core.executor.ArchTaskExecutor sInstance -> a",
);
assert_eq!(
    parsed,
    Ok(ProguardRecord::Field {
        ty: "android.arch.core.executor.ArchTaskExecutor",
        original: "sInstance",
        obfuscated: "a",
    })
);

// Method without line mappings
let parsed = ProguardRecord::try_parse(
    b"    java.lang.Object putIfAbsent(java.lang.Object,java.lang.Object) -> b",
);
assert_eq!(
    parsed,
    Ok(ProguardRecord::Method {
        ty: "java.lang.Object",
        original: "putIfAbsent",
        obfuscated: "b",
        arguments: "java.lang.Object,java.lang.Object",
        original_class: None,
        line_mapping: None,
    })
);

// Inlined method from foreign class
let parsed = ProguardRecord::try_parse(
    b"    1016:1016:void com.example1.domain.MyBean.doWork():16:16 -> buttonClicked",
);
assert_eq!(
    parsed,
    Ok(ProguardRecord::Method {
        ty: "void",
        original: "doWork",
        obfuscated: "buttonClicked",
        arguments: "",
        original_class: Some("com.example1.domain.MyBean"),
        line_mapping: Some(proguard::LineMapping {
            startline: 1016,
            endline: 1016,
            original_startline: Some(16),
            original_endline: Some(16),
        }),
    })
);

Trait Implementations§

source§

impl<'s> Clone for ProguardRecord<'s>

source§

fn clone(&self) -> ProguardRecord<'s>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'s> Debug for ProguardRecord<'s>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'s> PartialEq for ProguardRecord<'s>

source§

fn eq(&self, other: &ProguardRecord<'s>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'s> StructuralPartialEq for ProguardRecord<'s>

Auto Trait Implementations§

§

impl<'s> Freeze for ProguardRecord<'s>

§

impl<'s> RefUnwindSafe for ProguardRecord<'s>

§

impl<'s> Send for ProguardRecord<'s>

§

impl<'s> Sync for ProguardRecord<'s>

§

impl<'s> Unpin for ProguardRecord<'s>

§

impl<'s> UnwindSafe for ProguardRecord<'s>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.