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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//! HarmonyOS package metadata: the descriptors at the root of a HAP/HSP,
//! read from bytes the caller supplies (no zip or file IO here).
//!
//! - [`ModuleJson`]: `module.json`, the manifest. Abilities and extension
//! abilities with their `exported` flag, required permissions, skills
//! and deep-link URIs; requested and defined permissions.
//! - [`PackInfo`]: `pack.info`, the packing tool's digest of the bundle.
//! - [`PkgContextInfo`]: `pkgContextInfo.json`, the package table that
//! `.abc` record names and import requests refer to.
//! - [`PageList`] and [`RouterMap`]: the page list and the navigation route
//! table `module.json` names (`$profile:main_pages`, `$profile:router_map`).
//! - [`ResourceIndex`]: `resources.index`, the compiled resource table:
//! what the ids in compiled `$r(...)` calls and the `$string:name`
//! references of `module.json` stand for.
//! - [`SourceMaps`]: `ets/sourceMaps.map` of a debug build, from the lines of
//! the compiled files the code was made from to the source.
//!
//! Every JSON type offers the same two texts: `summary()`, one fact per line
//! for `grep`, and `pretty()`, the document itself re-indented. The
//! summaries state what the documents say and pass no judgement.
//!
//! Parsing the JSON documents is tolerant: only input that is not a JSON object is an error.
//! A wrongly typed field is skipped and recorded in `notes`; a field the
//! model does not cover is listed in `unmodelled` and stays reachable
//! through `raw()`.
//!
//! ```
//! use asc_hap::ModuleJson;
//!
//! let manifest = ModuleJson::parse(
//! br#"{"app": {"bundleName": "com.x.y"},
//! "module": {"name": "entry", "abilities": [{
//! "name": "EntryAbility", "exported": true, "srcEntry": "./ets/entryability/EntryAbility.ets",
//! "skills": [{"actions": ["ohos.want.action.viewData"], "uris": [{"scheme": "xy", "host": "open"}]}]}]}}"#,
//! )?;
//! let ability = &manifest.module.abilities[0];
//! assert!(ability.is_exported());
//! assert_eq!(ability.deep_links(), ["xy://open"]);
//! assert!(manifest.summary().contains("deeplink EntryAbility xy://open\n"));
//! let records = manifest.record_names("./ets/entryability/EntryAbility.ets", None);
//! assert_eq!(records.candidates(), ["com.x.y/entry/ets/entryability/EntryAbility", "&entry/src/main/ets/entryability/EntryAbility&"]);
//! # Ok::<(), asc_hap::HapError>(())
//! ```
pub use ;
pub use ;
pub use ;
pub use ;
pub use RecordNames;
pub use ;
pub use ;
pub use Note;
/// Why a metadata document could not be read at all.