1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//! Parser for Baidu mobile category dictionary (`.bcd`) files.
use Path;
use ;
use crate::;
/// Parses a BCD dictionary from memory.
///
/// BCD shares Baidu's category-dictionary entry encoding with BDICT while
/// using a mobile header layout. Text and coding strings are not normalized.
///
/// # Examples
///
/// ```no_run
/// let bytes = std::fs::read("dictionary.bcd")?;
/// let dictionary = cidian::bcd::parse(&bytes)?;
/// println!("{} entries", dictionary.entries.len());
/// # Ok::<(), Box<dyn std::error::Error>>(())
/// ```
/// Parses a BCD dictionary from a file.
///
/// The result is identical to reading the file and passing its bytes to
/// [`parse`]. The file name does not alter dictionary metadata.
///
/// # Examples
///
/// ```no_run
/// let dictionary = cidian::bcd::parse_file("dictionary.bcd")?;
/// println!("{:?}", dictionary.metadata.name);
/// # Ok::<(), cidian::Error>(())
/// ```