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§
- Connection
Info - Holds the connection information that
MSFileParam
should use for reading. - MSBit
Field Flags - Bit field flags.
- MSControl
Flags - Parsing, packing and trace construction control flags.
- MSError
- A structure representing libmseed errors.
- MSFile
Param - A state container for reading miniSEED records.
- MSRecord
- miniSEED record structure.
- MSTrace
Id - A container for a trace identifier composed by
MSTraceSegment
s. - MSTrace
IdIter - An iterator for
MSTraceId
. - MSTrace
List - A container for
MSTraceId
s. - MSTrace
Segment - A container for a continuous trace segment.
- MSTrace
Segment Iter - An iterator for
MSTraceSegment
. - MSWriter
- Generic miniSEED record writer.
- Pack
Info - Struct providing miniSEED record packing information.
- Record
Detection - Structure returned by
detect()
. - Record
Display - Helper struct for printing
MSRecord
withformat!
and{}
. - TlPack
Info - Struct aggregating
MSTraceList
packing information. - Trace
List Display - Helper struct for printing
MSTraceList
withformat!
and{}
.
Enums§
- MSData
Encoding - An enumeration of possible data encodings.
- MSError
Code - An enumeration of possible errors that can happen when working with miniSEED records.
- MSSample
Type - An enumeration of possible sample types.
- MSSub
Seconds - Enumeration of subsecond format identifiers.
- MSTime
Format - Enumeration of time format identifiers.
Traits§
- Data
Sample Type - Into
Connection Info - 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
- Detect miniSEED record in buffer.
- factor_
multiplier_ to_ sample_ rate - Calculates the sample rate as samples per second (
Hz
) from SEED 2.x sample rate factor and multiplier. - pack_
header2 - Pack a miniSEED version 2 header into the specified buffer.
- pack_
header3 - Pack a miniSEED version 3 header into the specified buffer.
- pack_
raw - Low level function that packs raw data samples into miniSEED records.
- pack_
record - Pack record data into miniSEED records.
- pack_
trace_ list - Packs the trace lists’ data into miniSEED records.
- repack_
mseed3 - Repack a parsed miniSEED record into a version 3 record.
- seedchan2xchan
- Converts a SEED 2.x channel identifier to an extended channel identifier.
- xchan2seedchan
- Converts an extended channel identifier to a SEED 2.x channel identifier.