ferro_json_ui/assets/
leaflet.rs1pub const LEAFLET_JS: &str = include_str!("../../assets/leaflet/leaflet.js");
13
14pub const LEAFLET_CSS: &str = include_str!("../../assets/leaflet/leaflet.css");
17
18pub const LEAFLET_IMAGES: &[(&str, &[u8])] = &[
20 (
21 "layers.png",
22 include_bytes!("../../assets/leaflet/images/layers.png"),
23 ),
24 (
25 "layers-2x.png",
26 include_bytes!("../../assets/leaflet/images/layers-2x.png"),
27 ),
28 (
29 "marker-icon.png",
30 include_bytes!("../../assets/leaflet/images/marker-icon.png"),
31 ),
32 (
33 "marker-icon-2x.png",
34 include_bytes!("../../assets/leaflet/images/marker-icon-2x.png"),
35 ),
36 (
37 "marker-shadow.png",
38 include_bytes!("../../assets/leaflet/images/marker-shadow.png"),
39 ),
40];
41
42pub fn leaflet_image(name: &str) -> Option<&'static [u8]> {
44 LEAFLET_IMAGES
45 .iter()
46 .find(|(n, _)| *n == name)
47 .map(|(_, b)| *b)
48}
49
50#[cfg(test)]
51mod tests {
52 use super::*;
53
54 #[test]
55 #[allow(clippy::const_is_empty)]
56 fn embedded_leaflet_is_present() {
57 assert!(!LEAFLET_JS.is_empty(), "leaflet.js must be embedded");
58 assert!(
59 LEAFLET_CSS.contains(".leaflet-"),
60 "leaflet.css must be embedded"
61 );
62 assert!(LEAFLET_JS.contains("1.9.4"), "expected Leaflet 1.9.4");
63 assert_eq!(LEAFLET_IMAGES.len(), 5);
64 assert!(leaflet_image("marker-icon.png").is_some());
65 assert!(leaflet_image("nope.png").is_none());
66 }
67}