Skip to content

Commit 69382de

Browse files
committed
refactor(resource-manager): refactor resource manager and mark raw binding as deprecated
1 parent 09afce4 commit 69382de

File tree

18 files changed

+882
-121
lines changed

18 files changed

+882
-121
lines changed

Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ ohos-bundle-binding = { version = "0.0.1", path = "crates/bundle
77
ohos-init-binding = { version = "0.0.3", path = "crates/init" }
88
ohos-hilog-binding = { version = "0.1.0", path = "crates/hilog" }
99
ohos-asset-binding = { version = "0.0.1", path = "crates/asset" }
10-
ohos-raw-binding = { version = "0.1.0", path = "crates/raw" }
11-
ohos-resource-manager-binding = { version = "0.0.1", path = "crates/resource_manager" }
10+
ohos-resource-manager-binding = { version = "0.1.0", path = "crates/resource_manager" }
1211
ohos-ability-access-control-binding = { version = "0.0.1", path = "crates/ability_access_control" }
1312
ohos-xcomponent-binding = { version = "0.1.0", path = "crates/xcomponent" }
1413
ohos-arkui-binding = { version = "0.0.5", path = "crates/arkui" }
@@ -27,8 +26,7 @@ ohos-bundle-sys = { version = "0.0.2", path = "sys/ohos-bundle-s
2726
ohos-init-sys = { version = "0.0.2", path = "sys/ohos-init-sys" }
2827
ohos-hilogs-sys = { version = "0.0.2", path = "sys/ohos-hilogs-sys" }
2928
ohos-asset-sys = { version = "0.0.1", path = "sys/ohos-asset-sys" }
30-
ohos-raw-sys = { version = "0.1.0", path = "sys/ohos-raw-sys" }
31-
ohos-resource-manager-sys = { version = "0.0.2", path = "sys/ohos-resource-manager-sys" }
29+
ohos-resource-manager-sys = { version = "0.1.0", path = "sys/ohos-resource-manager-sys" }
3230
ohos-ability-access-control-sys = { version = "0.0.1", path = "sys/ohos-ability-access-control-sys" }
3331
ohos-xcomponent-sys = { version = "0.0.2", path = "sys/ohos-xcomponent-sys" }
3432
ohos-arkui-sys = { version = "0.0.1", path = "sys/ohos-arkui-sys" }

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ A set of HarmonyNext native module bindings for rust.
1010
| ohos-hilog-binding | ![Crates.io Version](https://img.shields.io/crates/v/ohos-hilog-binding) | [hilog](https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/_hi_log-V5) binding |
1111
| ohos-image-binding | ![Crates.io Version](https://img.shields.io/crates/v/ohos-image-binding) | [image](https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/image-V5) binding |
1212
| ohos-init-binding | ![Crates.io Version](https://img.shields.io/crates/v/ohos-init-binding) | [init](https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/init-V5) binding |
13-
| ohos-raw-binding | ![Crates.io Version](https://img.shields.io/crates/v/ohos-raw-binding) | [rawfile](https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/rawfile-V5) binding |
1413
| ohos-resource-manager-binding | ![Crates.io Version](https://img.shields.io/crates/v/ohos-resource-manager-binding) | [resource manager](https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/resourcemanager-V5) binding |
1514
| ohos-xcomponent-binding | ![Crates.io Version](https://img.shields.io/crates/v/ohos-xcomponent-binding) | [xcomponent](https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/_o_h___native_x_component-V5) binding |
1615
| ohos-display-binding | ![Crates.io Version](https://img.shields.io/crates/v/ohos-display-binding) | [display](https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/_o_h___display_manager-V5) binding |

crates/raw/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1-
# ohos-raw-binding
1+
# Note: This crate is deprecated. Please use `ohos-resource-manager-binding` instead.
2+
3+
## ohos-raw-binding
4+
5+
Using rust to get the raw file from application bundle.
6+
7+
For official guideline, you can see more with [document](https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/rawfile-guidelines).
8+
29

3-
Please note: this crate may have some bugs. If you can fix it, PR is welcome.

crates/resource_manager/Cargo.toml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
[package]
22
name = "ohos-resource-manager-binding"
3-
version = "0.0.1"
3+
version = "0.1.0"
44
edition = "2021"
55
license = "MIT OR Apache-2.0"
66
description = "OpenHarmony's resource manager binding for rust"
77

8+
[features]
9+
default = ["napi"]
10+
11+
# Using napi-ohos to create a raw file manager
12+
napi = ["dep:napi-ohos"]
13+
14+
815
[dependencies]
916
ohos-resource-manager-sys = { workspace = true }
10-
ohos-raw-binding = { workspace = true }
17+
napi-ohos = { workspace = true, optional = true }

crates/resource_manager/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# ohos-resource-manager-binding
22

3-
Please note: this crate may have some bugs. If you can fix it, PR is welcome.
3+
Using rust to implement the ResourceManager.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#[derive(Debug)]
2+
pub enum RawFileError {
3+
IsNotRawDir(String),
4+
FfiInnerError(String),
5+
}
6+
7+
impl std::fmt::Display for RawFileError {
8+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
9+
match self {
10+
RawFileError::IsNotRawDir(path) => write!(f, "Is not raw dir: {}", path),
11+
RawFileError::FfiInnerError(msg) => write!(f, "Ffi inner error: {}", msg),
12+
}
13+
}
14+
}
15+
16+
impl std::error::Error for RawFileError {}
File renamed without changes.

0 commit comments

Comments
 (0)