pub struct DataAccess<D: Read + Seek> { /* private fields */ }Expand description
Enables access to data stored in data_location. The data could be compressed and/or encoded
and stored with various different types. This information is captured in the data_description
Implementations§
Source§impl<D: Read + Seek> DataAccess<D>
impl<D: Read + Seek> DataAccess<D>
Sourcepub fn from_binary_data_array(
bda: &BinaryDataArray,
data_location: Arc<Mutex<D>>,
) -> Option<Self>
pub fn from_binary_data_array( bda: &BinaryDataArray, data_location: Arc<Mutex<D>>, ) -> Option<Self>
Create a DataAccess instance from a BinaryDataArray, using the specified data_location
Sourcepub fn encoded_length(&self) -> u64
pub fn encoded_length(&self) -> u64
Return the length (in bytes) of the data in the file
Sourcepub fn binary_type(&self) -> BinaryDataType
pub fn binary_type(&self) -> BinaryDataType
Returns the binary type of the data (e.g. 64-bit float)
Sourcepub fn as_f64(&self) -> Result<Vec<f64>, DataError>
pub fn as_f64(&self) -> Result<Vec<f64>, DataError>
Decode, decompress and convert (if necessary) data points to f64
Examples found in repository?
examples/rewrite.rs (line 32)
11fn main() {
12 let filename = "test/only_ms2_mzml.mzML";
13
14 let start = Instant::now();
15 let file = File::open(filename).unwrap();
16 let header_reader = BufReader::new(file);
17
18 let data_file = File::open(filename).unwrap();
19 let data_reader = BufReader::new(data_file);
20
21 let parser = ImzMLReader::new(header_reader, data_reader).unwrap();
22
23 let duration = start.elapsed();
24
25 for error in parser.errors() {
26 println!("{:?}", error);
27 }
28 println!("Time elapsed when parsing is: {:?}", duration);
29
30 let spectrum = parser.spectrum(0).unwrap();
31 let mzs = spectrum.mz_array().unwrap();
32 println!("Data: {:?}", mzs.as_f64());
33
34 let start = Instant::now();
35
36 let mut writer = ImzMLWriter::from_parser(&parser);
37
38 writer
39 .write(
40 "test/only_ms2_mzml.imzML",
41 ImzMLWritableSpectrumIterator::new(&parser),
42 RectangleImage::new(10, 10),
43 )
44 .unwrap();
45
46 // let file = File::create("test/only_ms2_mzml.imzML").unwrap();
47 // let mut writer = Writer::new_with_indent(BufWriter::new(file), b' ', 2);
48 // let decl_elem = quick_xml::events::BytesDecl::new(
49 // "1.1".as_ref(),
50 // Some("UTF-8".as_ref()),
51 // Some("yes".as_ref()),
52 // );
53 // writer
54 // .write_event(quick_xml::events::Event::Decl(decl_elem))
55 // .unwrap();
56
57 // parser.mzml().unwrap().write_xml(&mut writer).unwrap();
58 let duration = start.elapsed();
59 println!("Time elapsed when writing is: {:?}", duration);
60}Trait Implementations§
Auto Trait Implementations§
impl<D> Freeze for DataAccess<D>
impl<D> RefUnwindSafe for DataAccess<D>
impl<D> Send for DataAccess<D>where
D: Send,
impl<D> Sync for DataAccess<D>where
D: Send,
impl<D> Unpin for DataAccess<D>
impl<D> UnwindSafe for DataAccess<D>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more