DataAccess

Struct DataAccess 

Source
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>

Source

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

Source

pub fn offset(&self) -> u64

Return the offset (in the file) of the data

Source

pub fn encoded_length(&self) -> u64

Return the length (in bytes) of the data in the file

Source

pub fn binary_type(&self) -> BinaryDataType

Returns the binary type of the data (e.g. 64-bit float)

Source

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§

Source§

impl<D: Debug + Read + Seek> Debug for DataAccess<D>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,