Skip to main content

ResourceManager

Struct ResourceManager 

Source
pub struct ResourceManager {
    pub resource_manager: NonNull<NativeResourceManager>,
}
Expand description

Resource Manager

Fields§

§resource_manager: NonNull<NativeResourceManager>

Implementations§

Source§

impl ResourceManager

Source

pub fn new(env: Env, resource_manager: Object<'_>) -> Self

Use the resource manager from arkts to create a raw file manager. Be aware that none of these methods are thread-safe.

§Example
use napi_derive_ohos::napi;
use napi_ohos::{bindgen_prelude::Object, Env};
use ohos_raw_binding::Raw;

#[napi]
pub fn raw_example(
    env: Env,
    #[napi(ts_arg_type = "resourceManager.ResourceManager")] resource_manager: Object,
) -> i32 {
    let raw_manager = Raw::new(env, resource_manager);
    let raw_dir = raw_manager.open_dir("");
    let count = raw_dir.count();
    count
}
Source

pub fn from_raw(raw: *mut NativeResourceManager) -> Self

Source

pub fn open_dir<S: AsRef<str>>( &self, path: S, recursive: bool, ) -> Result<RawDir, RawFileError>

get raw file dirs

Source

pub fn is_raw_dir<S: AsRef<str>>(&self, path: S) -> bool

Source

pub fn drawable_descriptor( &self, id: u32, density: Option<ScreenDensity>, icon_type: Option<IconType>, ) -> Result<*mut *mut ArkUI_DrawableDescriptor, RawFileError>

Source

pub fn drawable_descriptor_by_name( &self, name: String, density: Option<ScreenDensity>, icon_type: Option<IconType>, ) -> Result<*mut *mut ArkUI_DrawableDescriptor, RawFileError>

Source

pub fn media( &self, res_id: u32, density: Option<ScreenDensity>, ) -> Result<Vec<u8>, RawFileError>

Source

pub fn media_base64( &self, res_id: u32, density: Option<ScreenDensity>, ) -> Result<Vec<u8>, RawFileError>

Source

pub fn media_by_name( &self, name: String, density: Option<ScreenDensity>, ) -> Result<Vec<u8>, RawFileError>

Source

pub fn media_base64_by_name( &self, name: String, density: Option<ScreenDensity>, ) -> Result<Vec<u8>, RawFileError>

Trait Implementations§

Source§

impl Drop for ResourceManager

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for ResourceManager

Source§

impl Sync for ResourceManager

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.