potree_embed/
lib.rs

1#![doc = include_str!("../README.md")]
2
3use rust_embed::Embed;
4
5/// A provider for the built `potree` assets so that they can be embedded into a
6/// Rust application binary.
7///
8/// [`potree`]: https://github.com/potree/potree
9#[derive(Embed)]
10#[folder = "built_assets"]
11pub struct PotreeAssets;
12
13#[cfg(test)]
14mod potree_assets_tests {
15    use super::*;
16
17    #[test]
18    fn should_return_the_correct_asset() {
19        // Act
20        let asset = PotreeAssets::get("build/potree/potree.js");
21
22        // Assert
23        assert!(asset.is_some());
24        assert_eq!(
25            asset.unwrap().metadata.sha256_hash(),
26            [
27                233, 119, 224, 43, 52, 46, 99, 100, 218, 253, 246, 139, 172, 68, 39, 198, 242, 64,
28                255, 127, 185, 52, 69, 21, 38, 118, 221, 238, 4, 116, 172, 95
29            ]
30        );
31    }
32
33    #[test]
34    fn should_return_none_for_non_existent_asset() {
35        // Act
36        let asset = PotreeAssets::get("build/no/asset.txt");
37
38        // Assert
39        assert!(asset.is_none());
40    }
41
42    #[test]
43    fn should_return_the_binary_decoder_worker() {
44        // Act
45        let asset = PotreeAssets::get("build/potree/workers/BinaryDecoderWorker.js");
46
47        // Assert
48        assert!(asset.is_some());
49    }
50}