Debian Codegraph @

src/lz4f/dictionary.rs

raw symbols SCIP
1 use super::{api::DictionaryHandle, Result};
2 use std::sync::Arc;
3
4 /// A pre-compiled dictionary for the efficient compression.
5 #[derive(Clone)]
6 pub struct Dictionary(Arc<DictionaryHandle>);
7
8 impl Dictionary {
9 /// Builds a new `Dictionary`.
10 pub fn new(data: &[u8]) -> Result<Self> {
11 Ok(Self(Arc::new(DictionaryHandle::new(data)?)))
12 }
13
14 pub(crate) fn handle(&self) -> &DictionaryHandle {
15 &self.0
16 }
17 }
18
19 #[cfg(test)]
20 mod tests {
21 use super::Dictionary;
22
23 #[test]
24 fn create_dictionary() {
25 assert!(Dictionary::new(&[]).is_ok());
26 assert!(Dictionary::new(&b"quick brown fox jumps over the lazy dog"[..]).is_ok());
27 }
28 }