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
impl MSTraceList
sourcepub fn new() -> MSResult<Self>
pub fn new() -> MSResult<Self>
Creates a new MSTraceList container.
sourcepub fn from_buffer(buf: &[u8], flags: MSControlFlags) -> MSResult<Self>
pub fn from_buffer(buf: &[u8], flags: MSControlFlags) -> MSResult<Self>
Creates a new MSTraceList from a buffer.
sourcepub fn iter(&self) -> MSTraceIdIter ⓘ
pub fn iter(&self) -> MSTraceIdIter ⓘ
Returns a forward iterator over the trace lists’ trace identifiers.
sourcepub fn insert(&mut self, rec: MSRecord, autoheal: bool) -> MSResult<()>
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.
sourcepub fn display(
&self,
time_format: MSTimeFormat,
detail: i8,
gap: i8,
version: i8
) -> TraceListDisplay<'_>
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.