Skip to main content

ContainerBuilder

Struct ContainerBuilder 

Source
pub struct ContainerBuilder { /* private fields */ }
Expand description

索引构建器:顺序添加条目,自动累加载荷偏移。

手工维护 offset 极易出错,且错了要到解压时才暴露。

Implementations§

Source§

impl ContainerBuilder

Source

pub fn new(root: impl Into<String>) -> Self

新建构建器。

Source

pub fn add_file( &mut self, path: Vec<String>, size: u64, hash: Option<[u8; 32]>, meta: EntryMeta, ) -> Result<()>

添加一个文件,偏移自动取当前游标位置。

§Errors

路径组件不安全,或累计偏移溢出时返回错误。

Source

pub fn add_dir(&mut self, path: Vec<String>, meta: EntryMeta) -> Result<()>

添加一个目录。

§Errors

路径组件不安全时返回错误。

添加一个符号链接。

§Errors

路径组件不安全时返回错误。

Source

pub const fn payload_len(&self) -> u64

当前累计的明文载荷长度。

Source

pub fn finish(self) -> Result<ContainerIndex>

完成构建。

§Errors

布局校验失败时返回错误。

Trait Implementations§

Source§

impl Debug for ContainerBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ContainerBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.