Skip to main content

EncryptOptions

Struct EncryptOptions 

Source
pub struct EncryptOptions {
Show 13 fields pub filename: Option<String>, pub preserve_extension: bool, pub compress: bool, pub zstd_level: i32, pub chunk_size: u32, pub cipher: CipherId, pub argon2: Argon2Params, pub write_content_hash: bool, pub thumbnail: Option<Vec<u8>>, pub media_meta: Option<Vec<u8>>, pub moov_cache: Option<Vec<u8>>, pub folder_index: Option<Vec<u8>>, pub slot_directory: Option<Vec<u8>>,
}
Expand description

加密选项。

Fields§

§filename: Option<String>

原始文件名。为 None 时不写入文件名 TLV。

§preserve_extension: bool

是否以明文保留后缀。便于在不解密的情况下按类型筛选,但会泄露文件类型。

§compress: bool

是否启用 zstd 压缩。

§zstd_level: i32

zstd 压缩级别(1–22)。

§chunk_size: u32

明文分块大小。

§cipher: CipherId

AEAD 算法。

§argon2: Argon2Params

Argon2 参数。

§write_content_hash: bool

是否写入内容哈希以支持解密后自检。

§thumbnail: Option<Vec<u8>>

加密缩略图数据(WebP/JPEG),建议不超过 32 KB。

§media_meta: Option<Vec<u8>>

媒体元信息 JSON。

§moov_cache: Option<Vec<u8>>

MP4 的 moov box 副本,用于加速起播(规范 §4.4 的 0x0006)。

播放时先从这里取元数据,省掉「seek 到尾部读 moov」的两次额外往返。 收益最大的两个场景:

  • 局域网远程播放:省掉真实网络 RTT
  • 缺片播放:每个分片的冗余 header 都带一份,只要任意一片存在就能起播 (文档 05 §7.4)

与 TRANSCODED 不同,这个副本不改动载荷,原文件仍可 bit-for-bit 还原。

§folder_index: Option<Vec<u8>>

目录容器索引(ContainerIndex::encode 的输出)。

置位时会写入 CRITICAL+ENCRYPTED 的 TLV_FOLDER_INDEX 并设置 CONTAINER flag。CRITICAL 是必需的:不认识该 TLV 的实现必须拒绝打开, 否则会把容器误当作普通文件解出一堆拼接的字节。

§slot_directory: Option<Vec<u8>>

槽位目录(可管理模式,SlotDirectory::encode 的输出,固定 24 字节)。

置位时写入 CRITICAL+ENCRYPTED 的 TLV_SLOT_DIRECTORY 并设置 SLOT_DIRECTORY flag,即规范 §3.5 的「可管理模式」。

为 None 时是默认的可否认模式:槽位不可枚举,连文件的主人也分不清 哪个槽是谁的。两种模式在加密时二选一,同一个 vault 内不应混用—— 同目录下 5 个可否认文件混 1 个可管理文件,那 1 个的存在本身就是信号。

Trait Implementations§

Source§

impl Clone for EncryptOptions

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EncryptOptions

Source§

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

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

impl Default for EncryptOptions

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.