remote_settings/macros.rs
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
#[macro_export]
macro_rules! packaged_collections {
($(($bucket:expr, $collection:expr)),* $(,)?) => {
fn get_packaged_data(collection_name: &str) -> Option<&'static str> {
match collection_name {
$($collection => Some(include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/dumps/",
$bucket,
"/",
$collection,
".json"
))),)*
_ => None,
}
}
};
}
#[macro_export]
macro_rules! packaged_attachments {
() => {
fn get_packaged_attachment(collection_name: &str, filename: &str) -> Option<(&'static [u8], &'static str)> {
None
}
};
($(($bucket:expr, $collection:expr) => [$($filename:expr),* $(,)?]),* $(,)?) => {
fn get_packaged_attachment(collection_name: &str, filename: &str) -> Option<(&'static [u8], &'static str)> {
match (collection_name, filename) {
$($(
($collection, $filename) => Some((
include_bytes!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/dumps/",
$bucket,
"/attachments/",
$collection,
"/",
$filename
)),
include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/dumps/",
$bucket,
"/attachments/",
$collection,
"/",
$filename,
".meta.json"
))
)),
)*)*
_ => None,
}
}
};
}