pub struct ContainerIndex {
pub root: String,
pub entries: Vec<ContainerEntry>,
}Expand description
容器目录索引。
Fields§
§root: String原始根目录名,仅用于显示。
entries: Vec<ContainerEntry>全部条目。
Implementations§
Source§impl ContainerIndex
impl ContainerIndex
Sourcepub fn total_size(&self) -> u64
pub fn total_size(&self) -> u64
文件条目总字节数——即容器明文载荷的长度。
Sourcepub fn file_count(&self) -> usize
pub fn file_count(&self) -> usize
文件条目数量。
Sourcepub fn find(&self, display_path: &str) -> Option<&ContainerEntry>
pub fn find(&self, display_path: &str) -> Option<&ContainerEntry>
按显示路径查找条目。
Sourcepub fn encode(&self) -> Vec<u8> ⓘ
pub fn encode(&self) -> Vec<u8> ⓘ
编码为 TLV_FOLDER_INDEX 的明文内容。
自定义紧凑二进制格式而非 JSON:索引可能上到 10 MB 量级, 且要在移动端解析,避免文本格式的体积与解析开销。
布局:
u16 version
u16 root_len root 的 UTF-8 字节数
u32 entry_count
... root 字节
每个条目:
u8 kind
u8 flags bit0=有 hash, bit1=有 target, bit2=有 meta
u16 component_count
u64 offset
u64 size
每个组件: u16 len + 字节
[hash 32B]
[u16 target_len + 字节]
[meta 块]Sourcepub fn parse(data: &[u8]) -> Result<Self>
pub fn parse(data: &[u8]) -> Result<Self>
从 TLV_FOLDER_INDEX 的明文内容解析。
同时完成路径安全校验与载荷区间自洽性检查——不把这些留给调用方。
§Errors
输入畸形、路径不安全、区间越界或声明长度与实际不符时返回
[bad]。
Sourcepub fn validate_layout(&self) -> Result<()>
pub fn validate_layout(&self) -> Result<()>
Trait Implementations§
Source§impl Clone for ContainerIndex
impl Clone for ContainerIndex
Source§impl Debug for ContainerIndex
impl Debug for ContainerIndex
Source§impl Default for ContainerIndex
impl Default for ContainerIndex
impl Eq for ContainerIndex
Source§impl PartialEq for ContainerIndex
impl PartialEq for ContainerIndex
impl StructuralPartialEq for ContainerIndex
Auto Trait Implementations§
impl Forget for ContainerIndex
impl Freeze for ContainerIndex
impl RefUnwindSafe for ContainerIndex
impl Send for ContainerIndex
impl Sync for ContainerIndex
impl Unpin for ContainerIndex
impl UnsafeUnpin for ContainerIndex
impl UnwindSafe for ContainerIndex
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