From e9f2f06ea3aa0ce20d73b9f4e622d26ebdf25b47 Mon Sep 17 00:00:00 2001 From: southorange0929 Date: Wed, 26 Jun 2024 11:05:13 +0800 Subject: [PATCH] feat: add update query remove implenment --- crates/asset/src/data.rs | 124 +++++++++++++++++++++++++++++++++ crates/asset/src/error.rs | 141 ++++++++++++++++++++++++++++++++++++++ crates/asset/src/lib.rs | 84 +++++++++++++++-------- crates/asset/src/type.rs | 134 +++++++++++++++++++----------------- 4 files changed, 390 insertions(+), 93 deletions(-) create mode 100644 crates/asset/src/error.rs diff --git a/crates/asset/src/data.rs b/crates/asset/src/data.rs index 45244b8..12be89b 100644 --- a/crates/asset/src/data.rs +++ b/crates/asset/src/data.rs @@ -14,3 +14,127 @@ pub struct AssetAttr { pub tag: AssetTag, pub value: AssetValue, } + +impl From<&AssetAttr> for ohos_asset_sys::Asset_Attr { + fn from(value: &AssetAttr) -> Self { + match &value.value { + AssetValue::Blob(blob) => { + let b = ohos_asset_sys::Asset_Blob { + size: blob.len() as u32, + data: blob.as_ptr() as *mut u8, + }; + ohos_asset_sys::Asset_Attr { + tag: value.tag.into(), + value: ohos_asset_sys::Asset_Value { blob: b }, + } + } + AssetValue::Boolean(boolean) => ohos_asset_sys::Asset_Attr { + tag: value.tag.into(), + value: ohos_asset_sys::Asset_Value { + boolean: boolean.to_owned(), + }, + }, + AssetValue::U32IntT(uint32_t) => ohos_asset_sys::Asset_Attr { + tag: value.tag.into(), + value: ohos_asset_sys::Asset_Value { + u32_: uint32_t.to_owned(), + }, + }, + } + } +} + +pub struct AssetResult { + pub count: u32, + pub attrs: Vec, +} + +impl From<*mut ohos_asset_sys::Asset_Result> for AssetResult { + fn from(value: *mut ohos_asset_sys::Asset_Result) -> Self { + unsafe { + let raw_result = &*value; + let mut attrs = Vec::with_capacity(raw_result.count as usize); + for i in 0..raw_result.count as isize { + let raw_attr = &*raw_result.attrs.offset(i); + attrs.push(AssetAttr { + tag: raw_attr.tag.into(), + value: match raw_attr.tag & ohos_asset_sys::ASSET_TAG_TYPE_MASK { + ohos_asset_sys::Asset_TagType_ASSET_TYPE_BOOL => { + AssetValue::Boolean(raw_attr.value.boolean) + } + ohos_asset_sys::Asset_TagType_ASSET_TYPE_NUMBER => { + AssetValue::U32IntT(raw_attr.value.u32_) + } + ohos_asset_sys::Asset_TagType_ASSET_TYPE_BYTES => { + let blob = raw_attr.value.blob; + let data_slice = + std::slice::from_raw_parts(blob.data, blob.size as usize); + AssetValue::Blob(ManuallyDrop::new(data_slice.to_vec())) + } + _ => unimplemented!(), + }, + }); + } + AssetResult { + count: raw_result.count, + attrs, + } + } + } +} + +pub struct AssetResultSet { + pub count: u32, + pub result: Vec, +} + +impl From<*mut ohos_asset_sys::Asset_ResultSet> for AssetResultSet { + fn from(raw: *mut ohos_asset_sys::Asset_ResultSet) -> Self { + unsafe { + let mut results = Vec::new(); + if raw.is_null() { + return AssetResultSet { + count: 0, + result: results, + }; + } + + let raw_result_set = &*raw; + for i in 0..raw_result_set.count as isize { + let raw_result = &*raw_result_set.results.offset(i); + let mut attrs = Vec::new(); + for j in 0..raw_result.count as isize { + let raw_attr = &*raw_result.attrs.offset(j); + let value = match raw_attr.tag & ohos_asset_sys::ASSET_TAG_TYPE_MASK { + ohos_asset_sys::Asset_TagType_ASSET_TYPE_BOOL => { + AssetValue::Boolean(raw_attr.value.boolean) + } + ohos_asset_sys::Asset_TagType_ASSET_TYPE_NUMBER => { + AssetValue::U32IntT(raw_attr.value.u32_) + } + ohos_asset_sys::Asset_TagType_ASSET_TYPE_BYTES => { + let blob = raw_attr.value.blob; + let data_slice = + std::slice::from_raw_parts(blob.data, blob.size as usize); + AssetValue::Blob(ManuallyDrop::new(data_slice.to_vec())) + } + _ => unimplemented!(), + }; + attrs.push(AssetAttr { + tag: raw_attr.tag.into(), + value, + }); + } + results.push(AssetResult { + count: raw_result.count, + attrs, + }); + } + + AssetResultSet { + count: raw_result_set.count, + result: results, + } + } + } +} diff --git a/crates/asset/src/error.rs b/crates/asset/src/error.rs new file mode 100644 index 0000000..2710255 --- /dev/null +++ b/crates/asset/src/error.rs @@ -0,0 +1,141 @@ +use core::fmt; +use std::fmt::{Debug, Display}; + +#[derive(Debug, PartialEq)] +pub enum AssetResultCode { + Success, + PermissionDenied, + InvalidArgument, + ServiceUnavailable, + NotFound, + Duplicated, + AccessDenied, + StatusMismatch, + OutOfMemory, + DataCorrupted, + DatabaseError, + CryptoError, + IpcError, + BmsError, + AccountError, + AccessTokenError, + FileOperationError, + GetSystemTimeError, + LimitExceeded, + Unsupported, + UnknownError(u32), +} + +impl From for AssetResultCode { + fn from(code: ohos_asset_sys::Asset_ResultCode) -> Self { + match code { + ohos_asset_sys::Asset_ResultCode_ASSET_SUCCESS => AssetResultCode::Success, + ohos_asset_sys::Asset_ResultCode_ASSET_PERMISSION_DENIED => { + AssetResultCode::PermissionDenied + } + ohos_asset_sys::Asset_ResultCode_ASSET_INVALID_ARGUMENT => { + AssetResultCode::InvalidArgument + } + ohos_asset_sys::Asset_ResultCode_ASSET_SERVICE_UNAVAILABLE => { + AssetResultCode::ServiceUnavailable + } + ohos_asset_sys::Asset_ResultCode_ASSET_NOT_FOUND => AssetResultCode::NotFound, + ohos_asset_sys::Asset_ResultCode_ASSET_DUPLICATED => AssetResultCode::Duplicated, + ohos_asset_sys::Asset_ResultCode_ASSET_ACCESS_DENIED => AssetResultCode::AccessDenied, + ohos_asset_sys::Asset_ResultCode_ASSET_STATUS_MISMATCH => { + AssetResultCode::StatusMismatch + } + ohos_asset_sys::Asset_ResultCode_ASSET_OUT_OF_MEMORY => AssetResultCode::OutOfMemory, + ohos_asset_sys::Asset_ResultCode_ASSET_DATA_CORRUPTED => AssetResultCode::DataCorrupted, + ohos_asset_sys::Asset_ResultCode_ASSET_DATABASE_ERROR => AssetResultCode::DatabaseError, + ohos_asset_sys::Asset_ResultCode_ASSET_CRYPTO_ERROR => AssetResultCode::CryptoError, + ohos_asset_sys::Asset_ResultCode_ASSET_IPC_ERROR => AssetResultCode::IpcError, + ohos_asset_sys::Asset_ResultCode_ASSET_BMS_ERROR => AssetResultCode::BmsError, + ohos_asset_sys::Asset_ResultCode_ASSET_ACCOUNT_ERROR => AssetResultCode::AccountError, + ohos_asset_sys::Asset_ResultCode_ASSET_ACCESS_TOKEN_ERROR => { + AssetResultCode::AccessTokenError + } + ohos_asset_sys::Asset_ResultCode_ASSET_FILE_OPERATION_ERROR => { + AssetResultCode::FileOperationError + } + ohos_asset_sys::Asset_ResultCode_ASSET_GET_SYSTEM_TIME_ERROR => { + AssetResultCode::GetSystemTimeError + } + ohos_asset_sys::Asset_ResultCode_ASSET_LIMIT_EXCEEDED => AssetResultCode::LimitExceeded, + ohos_asset_sys::Asset_ResultCode_ASSET_UNSUPPORTED => AssetResultCode::Unsupported, + c => AssetResultCode::UnknownError(c), + } + } +} + +impl AssetResultCode { + pub fn to_result_code(self) -> ohos_asset_sys::Asset_ResultCode { + match self { + AssetResultCode::Success => ohos_asset_sys::Asset_ResultCode_ASSET_SUCCESS, + AssetResultCode::PermissionDenied => { + ohos_asset_sys::Asset_ResultCode_ASSET_PERMISSION_DENIED + } + AssetResultCode::InvalidArgument => { + ohos_asset_sys::Asset_ResultCode_ASSET_INVALID_ARGUMENT + } + AssetResultCode::ServiceUnavailable => { + ohos_asset_sys::Asset_ResultCode_ASSET_SERVICE_UNAVAILABLE + } + AssetResultCode::NotFound => ohos_asset_sys::Asset_ResultCode_ASSET_NOT_FOUND, + AssetResultCode::Duplicated => ohos_asset_sys::Asset_ResultCode_ASSET_DUPLICATED, + AssetResultCode::AccessDenied => ohos_asset_sys::Asset_ResultCode_ASSET_ACCESS_DENIED, + AssetResultCode::StatusMismatch => { + ohos_asset_sys::Asset_ResultCode_ASSET_STATUS_MISMATCH + } + AssetResultCode::OutOfMemory => ohos_asset_sys::Asset_ResultCode_ASSET_OUT_OF_MEMORY, + AssetResultCode::DataCorrupted => ohos_asset_sys::Asset_ResultCode_ASSET_DATA_CORRUPTED, + AssetResultCode::DatabaseError => ohos_asset_sys::Asset_ResultCode_ASSET_DATABASE_ERROR, + AssetResultCode::CryptoError => ohos_asset_sys::Asset_ResultCode_ASSET_CRYPTO_ERROR, + AssetResultCode::IpcError => ohos_asset_sys::Asset_ResultCode_ASSET_IPC_ERROR, + AssetResultCode::BmsError => ohos_asset_sys::Asset_ResultCode_ASSET_BMS_ERROR, + AssetResultCode::AccountError => ohos_asset_sys::Asset_ResultCode_ASSET_ACCOUNT_ERROR, + AssetResultCode::AccessTokenError => { + ohos_asset_sys::Asset_ResultCode_ASSET_ACCESS_TOKEN_ERROR + } + AssetResultCode::FileOperationError => { + ohos_asset_sys::Asset_ResultCode_ASSET_FILE_OPERATION_ERROR + } + AssetResultCode::GetSystemTimeError => { + ohos_asset_sys::Asset_ResultCode_ASSET_GET_SYSTEM_TIME_ERROR + } + AssetResultCode::LimitExceeded => ohos_asset_sys::Asset_ResultCode_ASSET_LIMIT_EXCEEDED, + AssetResultCode::Unsupported => ohos_asset_sys::Asset_ResultCode_ASSET_UNSUPPORTED, + AssetResultCode::UnknownError(_code) => unimplemented!(), + } + } +} + +impl Display for AssetResultCode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> fmt::Result { + match self { + AssetResultCode::Success => write!(f, "Success"), + AssetResultCode::PermissionDenied => write!(f, "Permission denied"), + AssetResultCode::InvalidArgument => write!(f, "Invalid argument"), + AssetResultCode::ServiceUnavailable => write!(f, "The ASSET service is unavailable."), + AssetResultCode::NotFound => write!(f, "The asset is not found."), + AssetResultCode::Duplicated => write!(f, "The asset already exists."), + AssetResultCode::AccessDenied => write!(f, "Access to the asset is denied."), + AssetResultCode::StatusMismatch => write!(f, "The screen lock status does not match."), + AssetResultCode::OutOfMemory => write!(f, "Insufficient memory."), + AssetResultCode::DataCorrupted => write!(f, "The asset is corrupted."), + AssetResultCode::DatabaseError => write!(f, "The database operation failed."), + AssetResultCode::CryptoError => write!(f, "The cryptography operation failed."), + AssetResultCode::IpcError => write!(f, "IPC failed."), + AssetResultCode::BmsError => write!(f, "Calling the Bundle Manager service failed."), + AssetResultCode::AccountError => write!(f, "Calling the OS Account service failed."), + AssetResultCode::AccessTokenError => { + write!(f, "Calling the Access Token service failed.") + } + AssetResultCode::FileOperationError => write!(f, "The file operation failed."), + AssetResultCode::GetSystemTimeError => write!(f, "Getting the system time failed."), + AssetResultCode::LimitExceeded => write!(f, "The cache exceeds the limit."), + AssetResultCode::Unsupported => write!(f, "The capability is not supported."), + AssetResultCode::UnknownError(code) => write!(f, "Unknown error code: {}", code), + } + } +} diff --git a/crates/asset/src/lib.rs b/crates/asset/src/lib.rs index fdfae31..ceab912 100644 --- a/crates/asset/src/lib.rs +++ b/crates/asset/src/lib.rs @@ -1,38 +1,64 @@ mod data; +mod r#error; mod r#type; +use std::ptr; + pub use data::*; +pub use r#error::*; pub use r#type::*; /// add -pub fn asset_add(attrs: Vec) { +pub fn asset_add(attrs: Vec) -> AssetResultCode { + let count = attrs.len() as u32; + let real_attrs = attrs.iter().map(|a| a.into()).collect::>(); + let ret_status = unsafe { ohos_asset_sys::OH_Asset_Add(real_attrs.as_ptr(), count) }; + AssetResultCode::from(ret_status as u32) +} + +/// query +/// note: If you're trying to access key assets that require user authentication, make sure to run the function asset_pre_query first. +pub fn asset_query(attrs: Vec) -> Result { + let count = attrs.len() as u32; + let real_attrs = attrs.iter().map(|a| a.into()).collect::>(); + let mut ret_set = ohos_asset_sys::Asset_ResultSet { + count: 0, + results: ptr::null_mut(), + }; + let query_status = + unsafe { ohos_asset_sys::OH_Asset_Query(real_attrs.as_ptr(), count, &mut ret_set) }; + let query_code = AssetResultCode::from(query_status as u32); + if query_code != AssetResultCode::Success { + return Err(query_code); + } + let ret = AssetResultSet::from((&mut ret_set) as *mut ohos_asset_sys::Asset_ResultSet); + + // free origin data + unsafe { ohos_asset_sys::OH_Asset_FreeResultSet(&mut ret_set) }; + Ok(ret) +} + +/// remove +pub fn asset_remove(attrs: Vec) -> AssetResultCode { let count = attrs.len() as u32; - let real_attrs = attrs - .iter() - .map(|a| match &a.value { - AssetValue::Blob(blob) => { - let b = ohos_asset_sys::Asset_Blob { - size: blob.len() as u32, - data: blob.as_ptr() as *mut u8, - }; - ohos_asset_sys::Asset_Attr { - tag: a.tag.into(), - value: ohos_asset_sys::Asset_Value { blob: b }, - } - } - AssetValue::Boolean(boolean) => ohos_asset_sys::Asset_Attr { - tag: a.tag.into(), - value: ohos_asset_sys::Asset_Value { - boolean: boolean.to_owned(), - }, - }, - AssetValue::U32IntT(uint32_t) => ohos_asset_sys::Asset_Attr { - tag: a.tag.into(), - value: ohos_asset_sys::Asset_Value { - u32_: uint32_t.to_owned(), - }, - }, - }) - .collect::>(); - unsafe { ohos_asset_sys::OH_Asset_Add(real_attrs.as_ptr(), count) }; + let real_attrs = attrs.iter().map(|a| a.into()).collect::>(); + let ret_status = unsafe { ohos_asset_sys::OH_Asset_Remove(real_attrs.as_ptr(), count) }; + AssetResultCode::from(ret_status as u32) +} + +/// update +pub fn asset_update(query_attrs: Vec, update_attrs: Vec) -> AssetResultCode { + let query_count = query_attrs.len() as u32; + let query_real_attrs = query_attrs.iter().map(|a| a.into()).collect::>(); + let update_count = update_attrs.len() as u32; + let update_real_attrs = update_attrs.iter().map(|a| a.into()).collect::>(); + let ret_status = unsafe { + ohos_asset_sys::OH_Asset_Update( + query_real_attrs.as_ptr(), + query_count, + update_real_attrs.as_ptr(), + update_count, + ) + }; + AssetResultCode::from(ret_status as u32) } diff --git a/crates/asset/src/type.rs b/crates/asset/src/type.rs index 6158bf9..c6ed46a 100644 --- a/crates/asset/src/type.rs +++ b/crates/asset/src/type.rs @@ -3,17 +3,7 @@ use ohos_asset_sys::{ Asset_Accessibility_ASSET_ACCESSIBILITY_DEVICE_POWERED_ON, Asset_Accessibility_ASSET_ACCESSIBILITY_DEVICE_UNLOCKED, Asset_AuthType_ASSET_AUTH_TYPE_ANY, Asset_AuthType_ASSET_AUTH_TYPE_NONE, Asset_ConflictResolution_ASSET_CONFLICT_OVERWRITE, - Asset_ConflictResolution_ASSET_CONFLICT_THROW_ERROR, Asset_ResultCode_ASSET_ACCESS_DENIED, - Asset_ResultCode_ASSET_ACCESS_TOKEN_ERROR, Asset_ResultCode_ASSET_ACCOUNT_ERROR, - Asset_ResultCode_ASSET_BMS_ERROR, Asset_ResultCode_ASSET_CRYPTO_ERROR, - Asset_ResultCode_ASSET_DATABASE_ERROR, Asset_ResultCode_ASSET_DATA_CORRUPTED, - Asset_ResultCode_ASSET_DUPLICATED, Asset_ResultCode_ASSET_FILE_OPERATION_ERROR, - Asset_ResultCode_ASSET_GET_SYSTEM_TIME_ERROR, Asset_ResultCode_ASSET_INVALID_ARGUMENT, - Asset_ResultCode_ASSET_IPC_ERROR, Asset_ResultCode_ASSET_LIMIT_EXCEEDED, - Asset_ResultCode_ASSET_NOT_FOUND, Asset_ResultCode_ASSET_OUT_OF_MEMORY, - Asset_ResultCode_ASSET_PERMISSION_DENIED, Asset_ResultCode_ASSET_SERVICE_UNAVAILABLE, - Asset_ResultCode_ASSET_STATUS_MISMATCH, Asset_ResultCode_ASSET_SUCCESS, - Asset_ResultCode_ASSET_UNSUPPORTED, Asset_ReturnType_ASSET_RETURN_ALL, + Asset_ConflictResolution_ASSET_CONFLICT_THROW_ERROR, Asset_ReturnType_ASSET_RETURN_ALL, Asset_ReturnType_ASSET_RETURN_ATTRIBUTES, Asset_SyncType_ASSET_SYNC_TYPE_NEVER, Asset_SyncType_ASSET_SYNC_TYPE_THIS_DEVICE, Asset_SyncType_ASSET_SYNC_TYPE_TRUSTED_ACCOUNT, Asset_SyncType_ASSET_SYNC_TYPE_TRUSTED_DEVICE, @@ -76,59 +66,6 @@ impl From for ohos_asset_sys::Asset_ConflictResolution } } -#[derive(Debug)] -pub enum AssetResultCode { - AssetSuccess, - AssetPermissionDenied, - AssetInvalidArgument, - AssetServiceUnavailable, - AssetNotFound, - AssetDuplicated, - AssetAccessDenied, - AssetStatusMismatch, - AssetOutOfMemory, - AssetDataCorrupted, - AssetDatabaseError, - AssetCryptoError, - AssetIpcError, - AssetBmsError, - AssetAccountError, - AssetAccessTokenError, - AssetFileOperationError, - AssetGetSystemTimeError, - AssetLimitExceeded, - AssetUnsupported, -} - -impl From for ohos_asset_sys::Asset_ResultCode { - fn from(value: AssetResultCode) -> Self { - match value { - AssetResultCode::AssetSuccess => Asset_ResultCode_ASSET_SUCCESS, - AssetResultCode::AssetPermissionDenied => Asset_ResultCode_ASSET_PERMISSION_DENIED, - AssetResultCode::AssetInvalidArgument => Asset_ResultCode_ASSET_INVALID_ARGUMENT, - AssetResultCode::AssetServiceUnavailable => Asset_ResultCode_ASSET_SERVICE_UNAVAILABLE, - AssetResultCode::AssetNotFound => Asset_ResultCode_ASSET_NOT_FOUND, - AssetResultCode::AssetDuplicated => Asset_ResultCode_ASSET_DUPLICATED, - AssetResultCode::AssetAccessDenied => Asset_ResultCode_ASSET_ACCESS_DENIED, - AssetResultCode::AssetStatusMismatch => Asset_ResultCode_ASSET_STATUS_MISMATCH, - AssetResultCode::AssetOutOfMemory => Asset_ResultCode_ASSET_OUT_OF_MEMORY, - AssetResultCode::AssetDataCorrupted => Asset_ResultCode_ASSET_DATA_CORRUPTED, - AssetResultCode::AssetDatabaseError => Asset_ResultCode_ASSET_DATABASE_ERROR, - AssetResultCode::AssetCryptoError => Asset_ResultCode_ASSET_CRYPTO_ERROR, - AssetResultCode::AssetIpcError => Asset_ResultCode_ASSET_IPC_ERROR, - AssetResultCode::AssetBmsError => Asset_ResultCode_ASSET_BMS_ERROR, - AssetResultCode::AssetAccountError => Asset_ResultCode_ASSET_ACCOUNT_ERROR, - AssetResultCode::AssetAccessTokenError => Asset_ResultCode_ASSET_ACCESS_TOKEN_ERROR, - AssetResultCode::AssetFileOperationError => Asset_ResultCode_ASSET_FILE_OPERATION_ERROR, - AssetResultCode::AssetGetSystemTimeError => { - Asset_ResultCode_ASSET_GET_SYSTEM_TIME_ERROR - } - AssetResultCode::AssetLimitExceeded => Asset_ResultCode_ASSET_LIMIT_EXCEEDED, - AssetResultCode::AssetUnsupported => Asset_ResultCode_ASSET_UNSUPPORTED, - } - } -} - #[derive(Debug)] pub enum AssetReturnType { AssetReturnAll, @@ -268,6 +205,75 @@ impl From for ohos_asset_sys::Asset_Tag { } } +impl From for AssetTag { + fn from(value: ohos_asset_sys::Asset_Tag) -> Self { + match value { + ohos_asset_sys::Asset_Tag_ASSET_TAG_SECRET => AssetTag::AssetTagSecret, + ohos_asset_sys::Asset_Tag_ASSET_TAG_ALIAS => AssetTag::AssetTagAlias, + ohos_asset_sys::Asset_Tag_ASSET_TAG_ACCESSIBILITY => AssetTag::AssetTagAccessibility, + ohos_asset_sys::Asset_Tag_ASSET_TAG_REQUIRE_PASSWORD_SET => { + AssetTag::AssetTagRequirePasswordSet + } + ohos_asset_sys::Asset_Tag_ASSET_TAG_AUTH_TYPE => AssetTag::AssetTagAuthType, + ohos_asset_sys::Asset_Tag_ASSET_TAG_AUTH_VALIDITY_PERIOD => { + AssetTag::AssetTagAuthValidityPeriod + } + ohos_asset_sys::Asset_Tag_ASSET_TAG_AUTH_CHALLENGE => AssetTag::AssetTagAuthChallenge, + ohos_asset_sys::Asset_Tag_ASSET_TAG_AUTH_TOKEN => AssetTag::AssetTagAuthToken, + ohos_asset_sys::Asset_Tag_ASSET_TAG_SYNC_TYPE => AssetTag::AssetTagSyncType, + ohos_asset_sys::Asset_Tag_ASSET_TAG_IS_PERSISTENT => AssetTag::AssetTagIsPersistent, + ohos_asset_sys::Asset_Tag_ASSET_TAG_DATA_LABEL_CRITICAL_1 => { + AssetTag::AssetTagDataLabelCritical1 + } + ohos_asset_sys::Asset_Tag_ASSET_TAG_DATA_LABEL_CRITICAL_2 => { + AssetTag::AssetTagDataLabelCritical2 + } + ohos_asset_sys::Asset_Tag_ASSET_TAG_DATA_LABEL_CRITICAL_3 => { + AssetTag::AssetTagDataLabelCritical3 + } + ohos_asset_sys::Asset_Tag_ASSET_TAG_DATA_LABEL_CRITICAL_4 => { + AssetTag::AssetTagDataLabelCritical4 + } + ohos_asset_sys::Asset_Tag_ASSET_TAG_DATA_LABEL_NORMAL_1 => { + AssetTag::AssetTagDataLabelNormal1 + } + ohos_asset_sys::Asset_Tag_ASSET_TAG_DATA_LABEL_NORMAL_2 => { + AssetTag::AssetTagDataLabelNormal2 + } + ohos_asset_sys::Asset_Tag_ASSET_TAG_DATA_LABEL_NORMAL_3 => { + AssetTag::AssetTagDataLabelNormal3 + } + ohos_asset_sys::Asset_Tag_ASSET_TAG_DATA_LABEL_NORMAL_4 => { + AssetTag::AssetTagDataLabelNormal4 + } + ohos_asset_sys::Asset_Tag_ASSET_TAG_DATA_LABEL_NORMAL_LOCAL_1 => { + AssetTag::AssetTagDataLabelNormalLocal1 + } + ohos_asset_sys::Asset_Tag_ASSET_TAG_DATA_LABEL_NORMAL_LOCAL_2 => { + AssetTag::AssetTagDataLabelNormalLocal2 + } + ohos_asset_sys::Asset_Tag_ASSET_TAG_DATA_LABEL_NORMAL_LOCAL_3 => { + AssetTag::AssetTagDataLabelNormalLocal3 + } + ohos_asset_sys::Asset_Tag_ASSET_TAG_DATA_LABEL_NORMAL_LOCAL_4 => { + AssetTag::AssetTagDataLabelNormalLocal4 + } + ohos_asset_sys::Asset_Tag_ASSET_TAG_RETURN_TYPE => AssetTag::AssetTagReturnType, + ohos_asset_sys::Asset_Tag_ASSET_TAG_RETURN_LIMIT => AssetTag::AssetTagReturnLimit, + ohos_asset_sys::Asset_Tag_ASSET_TAG_RETURN_OFFSET => AssetTag::AssetTagReturnOffset, + ohos_asset_sys::Asset_Tag_ASSET_TAG_RETURN_ORDERED_BY => { + AssetTag::AssetTagReturnOrderedBy + } + ohos_asset_sys::Asset_Tag_ASSET_TAG_CONFLICT_RESOLUTION => { + AssetTag::AssetTagConflictResolution + } + ohos_asset_sys::Asset_Tag_ASSET_TAG_UPDATE_TIME => AssetTag::AssetTagUpdateTime, + ohos_asset_sys::Asset_Tag_ASSET_TAG_OPERATION_TYPE => AssetTag::AssetTagOperationType, + _ => panic!("Unknown ohos_asset_sys::Asset_Tag value: {}", value), + } + } +} + #[derive(Debug)] pub enum AssetTagType { AssetTypeBool,