lindera_dictionary/
macros.rs1#[macro_export]
6macro_rules! decompress_data {
7 ($name: ident, $bytes: expr, $filename: literal) => {
8 #[cfg(feature = "compress")]
9 static $name: once_cell::sync::Lazy<Vec<u8>> = once_cell::sync::Lazy::new(|| {
10 use $crate::decompress::{CompressedData, decompress};
11
12 let mut aligned = rkyv::util::AlignedVec::<16>::new();
13 aligned.extend_from_slice(&$bytes[..]);
14 match rkyv::from_bytes::<CompressedData, rkyv::rancor::Error>(&aligned) {
15 Ok(compressed_data) => {
16 match decompress(compressed_data) {
18 Ok(decompressed) => decompressed,
19 Err(_) => {
20 $bytes.to_vec()
22 }
23 }
24 }
25 Err(_) => {
26 $bytes.to_vec()
28 }
29 }
30 });
31 #[cfg(not(feature = "compress"))]
32 const $name: &'static [u8] = $bytes;
33 };
34}