-
-
Notifications
You must be signed in to change notification settings - Fork 245
Expand file tree
/
Copy pathmapping.rs
More file actions
55 lines (45 loc) · 1.28 KB
/
mapping.rs
File metadata and controls
55 lines (45 loc) · 1.28 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use std::borrow::Cow;
use std::fmt::{Display, Formatter, Result as FmtResult};
use symbolic::common::{ByteView, DebugId};
use uuid::Uuid;
use crate::utils::chunks::Assemblable;
pub struct ProguardMapping<'a> {
bytes: ByteView<'a>,
uuid: Uuid,
}
impl ProguardMapping<'_> {
/// Get the UUID of the mapping.
pub fn uuid(&self) -> Uuid {
self.uuid
}
/// Force the UUID of the mapping to a specific value, rather
/// than the UUID which is derived from the proguard crate.
pub fn force_uuid(&mut self, uuid: Uuid) {
self.uuid = uuid;
}
}
impl<'a> From<ByteView<'a>> for ProguardMapping<'a> {
fn from(value: ByteView<'a>) -> Self {
let mapping = ::proguard::ProguardMapping::new(&value);
let uuid = mapping.uuid();
Self { bytes: value, uuid }
}
}
impl AsRef<[u8]> for ProguardMapping<'_> {
fn as_ref(&self) -> &[u8] {
self.bytes.as_ref()
}
}
impl Assemblable for ProguardMapping<'_> {
fn name(&self) -> Cow<'_, str> {
format!("/proguard/{}.txt", self.uuid).into()
}
fn debug_id(&self) -> Option<DebugId> {
None
}
}
impl Display for ProguardMapping<'_> {
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
write!(f, "{} (Proguard mapping)", self.uuid)
}
}