| 1 |
/* This Source Code Form is subject to the terms of the Mozilla Public |
| 2 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 4 |
|
| 5 |
#[macro_export] |
| 6 |
macro_rules! packaged_collections { |
| 7 |
($(($bucket:expr, $collection:expr)),* $(,)?) => { |
| 8 |
fn get_packaged_data(collection_name: &str) -> Option<&'static str> { |
| 9 |
match collection_name { |
| 10 |
$($collection => Some(include_str!(concat!( |
| 11 |
env!("CARGO_MANIFEST_DIR"), |
| 12 |
"/dumps/", |
| 13 |
$bucket, |
| 14 |
"/", |
| 15 |
$collection, |
| 16 |
".json" |
| 17 |
))),)* |
| 18 |
_ => None, |
| 19 |
} |
| 20 |
} |
| 21 |
}; |
| 22 |
} |
| 23 |
|
| 24 |
#[macro_export] |
| 25 |
macro_rules! packaged_attachments { |
| 26 |
() => { |
| 27 |
fn get_packaged_attachment(collection_name: &str, filename: &str) -> Option<(&'static [u8], &'static str)> { |
| 28 |
None |
| 29 |
} |
| 30 |
}; |
| 31 |
($(($bucket:expr, $collection:expr) => [$($filename:expr),* $(,)?]),* $(,)?) => { |
| 32 |
fn get_packaged_attachment(collection_name: &str, filename: &str) -> Option<(&'static [u8], &'static str)> { |
| 33 |
match (collection_name, filename) { |
| 34 |
$($( |
| 35 |
($collection, $filename) => Some(( |
| 36 |
include_bytes!(concat!( |
| 37 |
env!("CARGO_MANIFEST_DIR"), |
| 38 |
"/dumps/", |
| 39 |
$bucket, |
| 40 |
"/attachments/", |
| 41 |
$collection, |
| 42 |
"/", |
| 43 |
$filename |
| 44 |
)), |
| 45 |
include_str!(concat!( |
| 46 |
env!("CARGO_MANIFEST_DIR"), |
| 47 |
"/dumps/", |
| 48 |
$bucket, |
| 49 |
"/attachments/", |
| 50 |
$collection, |
| 51 |
"/", |
| 52 |
$filename, |
| 53 |
".meta.json" |
| 54 |
)) |
| 55 |
)), |
| 56 |
)*)* |
| 57 |
_ => None, |
| 58 |
} |
| 59 |
} |
| 60 |
}; |
| 61 |
} |