Crate mseed

source ·
Expand description

§libmseed bindings for Rust.

This library contains bindings to the libmseed C library which is used to manage miniSEED data. The library itself is a work in progress and is likely lacking some bindings here and there, so be warned.

The mseed library strives to be as close to libmseed as possible, but also strives to make using libmseed as safe as possible. All resource management is automatic as well as adding strong types to all interfaces (including MSResult).

§High-level miniSEED record I/O

Reading and writing miniSEED records is implemented by means of MSReader and MSWriter, respectively.

use std::fs::OpenOptions;

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

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

let out_file = OpenOptions::new().write(true).open("out.mseed").unwrap();
let mut writer = MSWriter::new(out_file);

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

    if msr.network().unwrap() == "NET" && msr.station().unwrap() == "STA" {
        // do something with msr

        writer
            .write_record(&msr, MSControlFlags::MSF_FLUSHDATA)
            .unwrap();
    }
}

§Low-level miniSEED record I/O

Creating miniSEED records from raw data samples is possible using the low-level pack_raw() function:

use std::fs::OpenOptions;
use std::io::{BufWriter, Write};

use time::format_description::well_known::Iso8601;
use time::OffsetDateTime;

use mseed::{self, MSControlFlags, PackInfo};

let pack_info = PackInfo::new("FDSN:XX_TEST__X_Y_Z").unwrap();

let file = OpenOptions::new()
    .create(true)
    .write(true)
    .open("path/to/out.mseed")
    .unwrap();
let mut writer = BufWriter::new(file);

let record_handler = move |rec: &[u8]| {
    let _ = writer.write(rec);
};

let mut data_samples: Vec<i32> = (1..100).collect();
let start_time = OffsetDateTime::parse("2012-01-01T00:00:00Z", &Iso8601::DEFAULT).unwrap();
mseed::pack_raw(
    &mut data_samples,
    &start_time,
    record_handler,
    &pack_info,
    MSControlFlags::MSF_FLUSHDATA,
)
.unwrap();

Structs§

Enums§

  • An enumeration of possible data encodings.
  • An enumeration of possible errors that can happen when working with miniSEED records.
  • An enumeration of possible sample types.
  • Enumeration of subsecond format identifiers.
  • Enumeration of time format identifiers.

Traits§

Functions§

  • Detect miniSEED record in buffer.
  • Calculates the sample rate as samples per second (Hz) from SEED 2.x sample rate factor and multiplier.
  • Pack a miniSEED version 2 header into the specified buffer.
  • Pack a miniSEED version 3 header into the specified buffer.
  • Low level function that packs raw data samples into miniSEED records.
  • Pack record data into miniSEED records.
  • Packs the trace lists’ data into miniSEED records.
  • Repack a parsed miniSEED record into a version 3 record.
  • Converts a SEED 2.x channel identifier to an extended channel identifier.
  • Converts an extended channel identifier to a SEED 2.x channel identifier.

Type Aliases§