Struct midasio::file::FileView

source ·
pub struct FileView<'a> { /* private fields */ }
Expand description

An immutable view to a MIDAS file.

A files is a collection of EventViews wrapped by two dumps of the Online Data Base (ODB) at the beginning and end of the sub-run. The binary representation of a file is:

Byte OffsetSize (in bytes)Description
02Begin-of-run marker (0x8000)
22Magic-midas marker (0x494D)
44Run number
84Initial unix timestamp
124Initial ODB dump size (n)
16nInitial ODB dump
16 + nmEvents
16 + n + m2End-of-run marker (0x8001)
18 + n + m2Magic-midas marker (0x494D)
20 + n + m4Run number
24 + n + m4Final unix timestamp
28 + n + m4Final ODB dump size (k)
32 + n + mkFinal ODB dump

Implementations§

source§

impl<'a> FileView<'a>

source

pub fn try_from_bytes( bytes: &'a [u8] ) -> Result<Self, TryFileViewFromBytesError>

Create a native view to the underlying file from its representation as a byte slice. Endianness is determined from the begin-of-run marker.

source

pub fn run_number(&self) -> u32

Return the run number associated with the file.

source

pub fn initial_timestamp(&self) -> u32

Return the unix timestamp of the initial ODB dump.

source

pub fn initial_odb(&self) -> &'a [u8]

Return the initial ODB dump. This is not guaranteed to be valid ASCII nor UTF-8.

source

pub fn final_timestamp(&self) -> u32

Return the unix timestamp of the final ODB dump.

source

pub fn final_odb(&self) -> &'a [u8]

Return the final ODB dump. This is not guaranteed to be valid ASCII nor UTF-8.

source

pub fn iter(&self) -> Iter<'_, EventView<'a>>

Return an iterator over the events in the file.

Trait Implementations§

source§

impl<'a> Clone for FileView<'a>

source§

fn clone(&self) -> FileView<'a>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a> Debug for FileView<'a>

source§

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

Formats the value using the given formatter. Read more
source§

impl<'a, 'b> IntoIterator for &'b FileView<'a>

§

type Item = &'b EventView<'a>

The type of the elements being iterated over.
§

type IntoIter = Iter<'b, EventView<'a>>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<'a> IntoIterator for FileView<'a>

§

type Item = EventView<'a>

The type of the elements being iterated over.
§

type IntoIter = IntoIter<EventView<'a>>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<'a, 'b> IntoParallelIterator for &'b FileView<'a>

Available on crate feature rayon only.
§

type Item = &'b EventView<'a>

The type of item that the parallel iterator will produce.
§

type Iter = Iter<'b, EventView<'a>>

The parallel iterator type that will be created.
source§

fn into_par_iter(self) -> Self::Iter

Converts self into a parallel iterator. Read more
source§

impl<'a> IntoParallelIterator for FileView<'a>

Available on crate feature rayon only.
§

type Item = EventView<'a>

The type of item that the parallel iterator will produce.
§

type Iter = IntoIter<EventView<'a>>

The parallel iterator type that will be created.
source§

fn into_par_iter(self) -> Self::Iter

Converts self into a parallel iterator. Read more
source§

impl<'a> TryFrom<&'a [u8]> for FileView<'a>

§

type Error = TryFileViewFromBytesError

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

fn try_from(bytes: &'a [u8]) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for FileView<'a>

§

impl<'a> Send for FileView<'a>

§

impl<'a> Sync for FileView<'a>

§

impl<'a> Unpin for FileView<'a>

§

impl<'a> UnwindSafe for FileView<'a>

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<'data, I> IntoParallelRefIterator<'data> for I
where I: 'data + ?Sized, &'data I: IntoParallelIterator,

§

type Iter = <&'data I as IntoParallelIterator>::Iter

The type of the parallel iterator that will be returned.
§

type Item = <&'data I as IntoParallelIterator>::Item

The type of item that the parallel iterator will produce. This will typically be an &'data T reference type.
source§

fn par_iter(&'data self) -> <I as IntoParallelRefIterator<'data>>::Iter

Converts self into a parallel iterator. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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

§

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.