pub struct ResourceManage { /* private fields */ }Expand description
资源管理器,维护文档中所有资源的 ID 索引。
对应 Java: org.ofdrw.reader.ResourceManage
提供按 ID 随机访问资源的能力。资源来源于 DocumentRes.xml 和 PublicRes.xml 中声明的资源序列。
Implementations§
Source§impl ResourceManage
impl ResourceManage
Sourcepub fn from_items(items: Vec<ResourceItem>) -> Self
pub fn from_items(items: Vec<ResourceItem>) -> Self
从资源条目列表构建资源管理器。
Sourcepub fn insert(&mut self, item: ResourceItem)
pub fn insert(&mut self, item: ResourceItem)
插入一个资源条目。如果 ID 已存在则覆盖。
Sourcepub fn get(&self, id: &str) -> Option<&ResourceItem>
pub fn get(&self, id: &str) -> Option<&ResourceItem>
按 ID 获取资源条目。
对应 Java: ResourceManage.get(String id)
Sourcepub fn all(&self) -> &HashMap<String, ResourceItem>
pub fn all(&self) -> &HashMap<String, ResourceItem>
获取所有资源条目。
Sourcepub fn ids_by_type(&self, resource_type: ResourceType) -> &[String]
pub fn ids_by_type(&self, resource_type: ResourceType) -> &[String]
按类型获取资源 ID 列表。
Sourcepub fn items_by_type(&self, resource_type: ResourceType) -> Vec<&ResourceItem>
pub fn items_by_type(&self, resource_type: ResourceType) -> Vec<&ResourceItem>
获取指定类型的全部资源条目。
Trait Implementations§
Source§impl Clone for ResourceManage
impl Clone for ResourceManage
Source§fn clone(&self) -> ResourceManage
fn clone(&self) -> ResourceManage
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ResourceManage
impl Debug for ResourceManage
Source§impl Default for ResourceManage
impl Default for ResourceManage
Source§fn default() -> ResourceManage
fn default() -> ResourceManage
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ResourceManage
impl RefUnwindSafe for ResourceManage
impl Send for ResourceManage
impl Sync for ResourceManage
impl Unpin for ResourceManage
impl UnsafeUnpin for ResourceManage
impl UnwindSafe for ResourceManage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more