pub struct SlotDirectory { /* private fields */ }Expand description
8 个槽位的目录。
Implementations§
Source§impl SlotDirectory
impl SlotDirectory
Sourcepub fn first_free(&self) -> Option<usize>
pub fn first_free(&self) -> Option<usize>
找一个真正空闲的槽位。
这正是可管理模式的核心价值:可否认模式下没有这种操作可用,add
只能把新密码写在 keep.len() 那个下标上,赌它原来是空的。
Sourcepub fn indices_of(&self, kind: SlotKind) -> Vec<usize>
pub fn indices_of(&self, kind: SlotKind) -> Vec<usize>
列出某个类型占用的全部下标。
Sourcepub fn decode(raw: &[u8]) -> Result<Self>
pub fn decode(raw: &[u8]) -> Result<Self>
从 24 字节解码。
§Errors
长度不是 DIRECTORY_LEN 时返回 Error::MalformedTlv。长度不对
就拒绝而不是尽力解析:目录与 slot 区必须严格对应,一个解析出 5 项
的「目录」比没有目录更危险——用户会拿它去删协作者。
Trait Implementations§
Source§impl Clone for SlotDirectory
impl Clone for SlotDirectory
impl Copy for SlotDirectory
Source§impl Debug for SlotDirectory
impl Debug for SlotDirectory
Source§impl Default for SlotDirectory
impl Default for SlotDirectory
impl Eq for SlotDirectory
Source§impl PartialEq for SlotDirectory
impl PartialEq for SlotDirectory
impl StructuralPartialEq for SlotDirectory
Auto Trait Implementations§
impl Forget for SlotDirectory
impl Freeze for SlotDirectory
impl RefUnwindSafe for SlotDirectory
impl Send for SlotDirectory
impl Sync for SlotDirectory
impl Unpin for SlotDirectory
impl UnsafeUnpin for SlotDirectory
impl UnwindSafe for SlotDirectory
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