lensbench_export/
detail.rs1use lensbench_core::math::V3;
9use std::sync::Arc;
10
11#[derive(Debug, Clone, Default)]
13pub struct Detail {
14 pub tris: Vec<[V3; 3]>,
15 pub step: Option<crate::step_embed::StepSource>,
17}
18
19pub trait DetailSource: Send + Sync {
21 fn load(&self, path: &str) -> Option<Arc<Detail>>;
22}
23
24impl<F: Fn(&str) -> Option<Arc<Detail>> + Send + Sync> DetailSource for F {
25 fn load(&self, path: &str) -> Option<Arc<Detail>> {
26 self(path)
27 }
28}
29
30#[derive(Clone)]
32pub struct Details(pub Arc<dyn DetailSource>);
33
34impl Details {
35 pub fn new(src: impl DetailSource + 'static) -> Details {
36 Details(Arc::new(src))
37 }
38
39 pub fn load(&self, path: &str) -> Option<Arc<Detail>> {
41 if path.is_empty() {
42 return None;
43 }
44 self.0.load(path)
45 }
46}
47
48impl std::fmt::Debug for Details {
49 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
50 f.write_str("Details(..)")
51 }
52}