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§
- Holds the connection information that
MSFileParam
should use for reading. - Bit field flags.
- Parsing, packing and trace construction control flags.
- A structure representing libmseed errors.
- A state container for reading miniSEED records.
- miniSEED record structure.
- A container for a trace identifier composed by
MSTraceSegment
s. - An iterator for
MSTraceId
. - A container for
MSTraceId
s. - A container for a continuous trace segment.
- An iterator for
MSTraceSegment
. - Generic miniSEED record writer.
- Struct providing miniSEED record packing information.
- Structure returned by
detect()
. - Struct aggregating
MSTraceList
packing information.
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§
- Converts an object into a
ConnectionInfo
struct. This allows the constructor of the client to accept a file path or an URL in a range of different formats.
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§
- Counterpart of
MSWriter
. - A specialized library
Result
type.