philips_isyntax_rs/
facade.rs1use crate::{ContainerName, Facade, Image, ImageType, Result};
5use cxx::let_cxx_string;
6use std::path::Path;
7
8impl Drop for Facade<'_> {
9 fn drop(&mut self) {
10 if let Err(_err) = self.close() {
11 };
13 }
14}
15
16impl Facade<'_> {
20 pub(crate) fn open_with_cache_file<P: AsRef<Path>, R: AsRef<Path>>(
23 &self,
24 filename: P,
25 container: &ContainerName,
26 cache_filename: R,
27 ) -> Result<()> {
28 let filename = filename.as_ref().display().to_string();
29 let cache_filename = cache_filename.as_ref().display().to_string();
30 Ok(self
31 .inner
32 .open(&filename, container.as_str(), &cache_filename)?)
33 }
34
35 fn close(&self) -> Result<()> {
39 Ok(self.inner.close()?)
40 }
41
42 pub fn num_images(&self) -> Result<usize> {
45 Ok(self.inner.numImages()?)
46 }
47
48 pub fn isyntax_file_version(&self) -> Result<&str> {
50 Ok(self.inner.iSyntaxFileVersion()?.to_str()?)
51 }
52
53 pub fn id(&self) -> Result<&str> {
56 Ok(self.inner.id()?.to_str()?)
57 }
58
59 pub fn barcode(&self) -> Result<&str> {
61 Ok(self.inner.barcode()?.to_str()?)
62 }
63
64 pub fn scanner_calibration_status(&self) -> Result<&str> {
66 Ok(self.inner.scannerCalibrationStatus()?.to_str()?)
67 }
68
69 pub fn software_versions(&self) -> Result<impl Iterator<Item = &str>> {
71 Ok(self
72 .inner
73 .softwareVersions()?
74 .iter()
75 .filter_map(|cxx_str| cxx_str.to_str().ok()))
76 }
77
78 pub fn derivation_description(&self) -> Result<&str> {
81 Ok(self.inner.derivationDescription()?.to_str()?)
82 }
83
84 pub fn acquisition_date_time(&self) -> Result<&str> {
86 Ok(self.inner.acquisitionDateTime()?.to_str()?)
87 }
88
89 pub fn manufacturer(&self) -> Result<&str> {
91 Ok(self.inner.manufacturer()?.to_str()?)
92 }
93
94 pub fn model_name(&self) -> Result<&str> {
96 Ok(self.inner.modelName()?.to_str()?)
97 }
98
99 pub fn device_serial_number(&self) -> Result<&str> {
101 Ok(self.inner.deviceSerialNumber()?.to_str()?)
102 }
103
104 pub fn scanner_rack_number(&self) -> Result<u16> {
106 Ok(self.inner.scannerRackNumber()?)
107 }
108
109 pub fn scanner_slot_number(&self) -> Result<u16> {
111 Ok(self.inner.scannerSlotNumber()?)
112 }
113
114 pub fn scanner_operator_id(&self) -> Result<&str> {
116 Ok(self.inner.scannerOperatorId()?.to_str()?)
117 }
118
119 pub fn scanner_rack_priority(&self) -> Result<u16> {
120 Ok(self.inner.scannerRackPriority()?)
121 }
122
123 pub fn date_of_last_calibration(&self) -> Result<impl Iterator<Item = &str>> {
125 Ok(self
126 .inner
127 .dateOfLastCalibration()?
128 .iter()
129 .filter_map(|cxx_str| cxx_str.to_str().ok()))
130 }
131
132 pub fn time_of_last_calibration(&self) -> Result<impl Iterator<Item = &str>> {
134 Ok(self
135 .inner
136 .timeOfLastCalibration()?
137 .iter()
138 .filter_map(|cxx_str| cxx_str.to_str().ok()))
139 }
140
141 pub fn is_philips(&self) -> Result<bool> {
143 Ok(self.inner.isPhilips()?)
144 }
145
146 pub fn is_hamamatsu(&self) -> Result<bool> {
148 Ok(self.inner.isHamamatsu()?)
149 }
150
151 pub fn is_ufs(&self) -> Result<bool> {
153 Ok(self.inner.isUFS()?)
154 }
155
156 pub fn is_ufsb(&self) -> Result<bool> {
157 Ok(self.inner.isUFSb()?)
158 }
159
160 pub fn is_uvs(&self) -> Result<bool> {
161 Ok(self.inner.isUVS()?)
162 }
163
164 pub fn image(&self, image_type: &ImageType) -> Result<Image<'_>> {
170 let_cxx_string!(image_type = image_type);
171 Ok(Image {
172 inner: self.inner.image(&image_type)?,
173 _lifetime: Default::default(),
174 })
175 }
176}
177
178impl ContainerName {
179 pub fn as_str(&self) -> &str {
180 match &self {
181 Self::Default => "",
182 Self::Ficom => "ficom",
183 Self::Dicom => "dicom",
184 Self::CachingFicom => "caching-ficom",
185 Self::S3 => "s3",
186 Self::Legacy => "legacy",
187 }
188 }
189}