ohos_web_binding/protocol/common/
mod.rs1use std::ffi::c_char;
2
3use ohos_web_sys::{OH_ArkWeb_ReleaseByteArray, OH_ArkWeb_ReleaseString};
4
5pub struct CommonString {
7 pub(crate) raw: *mut c_char,
8}
9
10impl Drop for CommonString {
11 fn drop(&mut self) {
12 unsafe {
13 OH_ArkWeb_ReleaseString(self.raw);
14 }
15 }
16}
17
18impl From<CommonString> for String {
19 fn from(value: CommonString) -> Self {
20 unsafe {
21 let s = std::ffi::CStr::from_ptr(value.raw);
22 s.to_string_lossy().to_string()
23 }
24 }
25}
26
27pub struct CommonBytes {
29 pub(crate) raw: *mut u8,
30}
31
32impl Drop for CommonBytes {
33 fn drop(&mut self) {
34 unsafe {
35 OH_ArkWeb_ReleaseByteArray(self.raw);
36 }
37 }
38}
39
40pub type ResponseCharset = CommonString;
43pub type ResponseHeaderKey = CommonString;
45pub type ResponseHeaderValue = CommonString;
47pub type ResponseMimeType = CommonString;
49pub type ResponseStatusText = CommonString;
51pub type Url = CommonString;
53pub type Method = CommonString;
55pub type Referrer = CommonString;