Expand description
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 theirexportedflag, 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.abcrecord names and import requests refer to.PageListandRouterMap: the page list and the navigation route tablemodule.jsonnames ($profile:main_pages,$profile:router_map).ResourceIndex:resources.index, the compiled resource table: what the ids in compiled$r(...)calls and the$string:namereferences ofmodule.jsonstand for.SourceMaps:ets/sourceMaps.mapof 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&"]);Structs§
- Ability
- An entry of
abilitiesorextensionAbilities. - ApiVersion
minAPIVersion/targetAPIVersionas written.- App
- The
appobject: bundle-wide facts. - Atomic
Service atomicService.- Attr
- A name with its value: a plural form, or an attribute of a theme or pattern.
- Define
Permission - An entry of
definePermissions. - Dependency
- A shared package (HSP) the module depends on.
- Metadata
- A
metadataentry: a literalvalue, a$profile:resource, or both. - Module
- The
moduleobject. - Module
Json - A parsed
module.json. - Module
Map - The source map of one module: which source line each line of the compiled file comes from.
- Multi
AppMode multiAppModeof theappobject.- Name
Value - A
name/valuepair (appEnvironments). - Note
- A field that was present but could not be used.
- Pack
Ability - An entry of a module’s
abilities. - PackApp
summary.app: bundle-wide facts.- Pack
Extension - An entry of a module’s
extensionAbilities. - Pack
Form - An entry of an extension’s
forms: one service widget. - Pack
Info - A parsed
pack.info. - Pack
Module - An entry of
summary.modules. - Pack
Package - An entry of
packages: one HAP/HSP file of the bundle. - Page
List - A parsed page list:
{"src": ["pages/Index", …]}. - PkgContext
- One package. Strings the file leaves empty stay empty here: the file
itself writes
""for “none”. - PkgContext
Info - A parsed
pkgContextInfo.json. - Proxy
Data - A
proxyDataentry: data shared through the data-share proxy. - Qualifier
- One key of a qualifier set with its stored value.
- Qualifiers
- The qualifiers one value of a resource was defined under. Empty is the
basedirectory, the value used when nothing more specific matches. - Record
Names - The record names a manifest
srcEntrycan compile to. Which spelling a package uses is a build option (normalized OHM URLs); packages built with it carry apkgContextInfo.json. - Record
Owner - A normalized record name split against the package table.
- Request
Permission - An entry of
requestPermissions. - Resource
- One value of one resource: its id, type, name, the qualifier set the value is for, and the value.
- Resource
Index - A parsed
resources.index, borrowing the bytes it was read from. - Resource
Ref - A reference to a resource by type and name, as
module.jsonwrites it ($string:app_name) or as source code does (app.string.app_name). - Resources
- Values of an index, from
ResourceIndex::iteror one of its lookups. - Route
- One route: a name the navigation stack is pushed with, and the builder function that makes its page.
- Router
Map - A parsed route table:
{"routerMap": [{…}, …]}. - Skill
- One entry of
skills: the implicit wants an ability accepts. - Skill
Uri - One entry of a skill’s
uris. - Source
Line - A line of one of the source files of a module.
- Source
Maps - The modules of an
ets/sourceMaps.map, by the record compiled from each. It holds no part of the file: the bytes are passed again to read a module. - Test
Runner testRunner.- Unknown
Resource Type - The text was not the name of a resource type.
Enums§
- Ability
Kind - Which array of the module an
Abilitycomes from. - HapError
- Why a metadata document could not be read at all.
- Index
Format - Which of the two layouts an index uses.
- Qualifier
Key - What a qualifier restricts.
- Resource
Index Error - Why a
resources.indexcould not be read. Offsets are file offsets. - Resource
Type - The type of a resource: the
stringof$string:app_nameand of$r('app.string.app_name'). - Resource
Value - What the index stores for one resource under one qualifier set. Every value is text in the file; text that is not UTF-8 is read lossily.
- Source
MapError - Why a source map table could not be read.