Struct mseed::MSTraceList

source ·
pub struct MSTraceList { /* private fields */ }
Expand description

A container for MSTraceIds.

Examples

Creating a MSTraceList from a file may be implemented as follows:

use std::fs::File;

use std::io::{Read, BufReader};

use mseed::{MSControlFlags, MSTraceList};

let file = File::open("path/to/data.mseed").unwrap();
let mut reader = BufReader::new(file);

let mut buf = Vec::new();
// read content of `data.mseed` into `buf`
reader.read_to_end(&mut buf).unwrap();

let mstl = MSTraceList::from_buffer(&buf, MSControlFlags::MSF_UNPACKDATA).unwrap();

If controlling the records to be inserted is desired, using MSReader is required:

use std::fs::File;

use mseed::{MSControlFlags, MSReader, MSTraceList};

let mut mstl = MSTraceList::new().unwrap();

let mut reader =
    MSReader::new_with_flags("path/to/data.mseed", MSControlFlags::MSF_UNPACKDATA).unwrap();

while let Some(res) = reader.next() {
    let msr = res.unwrap();

    if msr.network().unwrap() == "NET" && msr.station().unwrap() == "STA" {
        mstl.insert(msr, true).unwrap();
    }
}

// do something with `mstl`
let mstl_iter = mstl.iter();
for tid in mstl_iter {
    let tid_iter = tid.iter();
    for tseg in tid_iter {
        // do something with `tseg`
    }
}

Implementations§

source§

impl MSTraceList

source

pub fn new() -> MSResult<Self>

Creates a new MSTraceList container.

source

pub fn from_buffer(buf: &[u8], flags: MSControlFlags) -> MSResult<Self>

Creates a new MSTraceList from a buffer.

source

pub fn len(&self) -> c_uint

Returns the length of the trace list.

source

pub fn is_empty(&self) -> bool

Returns whether the trace list is empty.

source

pub fn iter(&self) -> MSTraceIdIter

Returns a forward iterator over the trace lists’ trace identifiers.

source

pub fn insert(&mut self, rec: MSRecord, autoheal: bool) -> MSResult<()>

Inserts rec into the trace list.

Note that currently MSTraceList does not implement deferred unpacking of data samples. Therefore, clients need to make sure that the rec inserted is unpacked, beforehand. If not doing so, the trace list will merely be a list of channels.

source

pub fn display( &self, time_format: MSTimeFormat, detail: i8, gap: i8, version: i8 ) -> TraceListDisplay<'_>

Returns an object that implements Display for printing a trace list summary.

By default only prints the FDSN source identifier, starttime and endtime for each trace. If detail is greater than zero the sample rate, number of samples and a total trace count is included. If gap is greater than zero and the previous trace matches both the FDSN source identifier and the sample rate the gap between the endtime of the last trace and the starttime of the current trace is included. If version is greater than zero, the publication version is included.

Trait Implementations§

source§

impl Debug for MSTraceList

source§

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

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

impl Drop for MSTraceList

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

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