pub struct Dict {
pub token_index: u32,
pub tokens: Arc<Vec<BdecodeToken>>,
pub buffer: Arc<Vec<u8>>,
pub item_indexes: Arc<Vec<u32>>,
/* private fields */
}Fields§
§token_index: u32当前节点在 tokens 中的索引 0 - root 节点值; -1 - 未初始化
tokens: Arc<Vec<BdecodeToken>>解析后的 token 集合
buffer: Arc<Vec<u8>>存放解析前字符串的 buffer
item_indexes: Arc<Vec<u32>>存放 list 和 map 中 item 的对应的 token 索引集合
Implementations§
Source§impl Dict
impl Dict
Sourcepub fn item(&self, index: usize) -> (BdecodeNode, BdecodeNode)
pub fn item(&self, index: usize) -> (BdecodeNode, BdecodeNode)
获取 dict 中指定索引的节点对(key, value)
Sourcepub fn find(&self, key: &[u8]) -> Option<BdecodeNode>
pub fn find(&self, key: &[u8]) -> Option<BdecodeNode>
在 dict 中查找 key 对应的 value
pub fn find_as_str(&self, key: &[u8]) -> Option<Cow<'_, [u8]>>
pub fn find_as_int(&self, key: &[u8]) -> Option<i64>
pub fn find_as_list(&self, key: &[u8]) -> Option<Vec<BdecodeNode>>
pub fn find_as_dict( &self, key: &[u8], ) -> Option<HashMap<Cow<'_, [u8]>, BdecodeNode>>
pub fn to_json(&self) -> String
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Dict
impl RefUnwindSafe for Dict
impl Send for Dict
impl Sync for Dict
impl Unpin for Dict
impl UnwindSafe for Dict
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