1 stable release

Uses old Rust 2015

1.0.1 Oct 18, 2017

#9 in #ds

MIT license

16KB
259 lines

seedlink

SeedLink Library for rust

SeedLink is a protocol for retrieving seismic data in realtime and semi-realtime from available servers

For information about the data formats and protocols, see:

Usage

Add this to your Cargo.toml:

[dependencies]
seedlink = "1.0.0"

and this to your crate root:

extern crate seedlink;

You will probably need include the miniseed crate as well;

Example

extern crate seedlink;
extern crate miniseed;

use seedlink::SeedLinkClient;

fn main() {

    let mut slc = SeedLinkClient::new("rtserve.iris.washington.edu",18000);

    let mut data = vec![0u8;2048];

    // Say Hello
    slc.hello().expect("bad write");

    // Read Response
    let n = slc.read(&mut data).expect("bad read");
    let v = data[..n].to_vec();
    let s = String::from_utf8(v).expect("Found invalid UTF-8");
    println!("data: {:?}", s);

    // Initiate Data Stream
    slc.start().expect("bad write");

    let mut buf = vec![];
    // Read Response
    loop {
        println!("Waiting on read ...");
        let n = slc.read(&mut data).expect("bad read");
        buf.extend(data[..n].iter().cloned());

        if buf.len() >= 520 {
            // Parse data
            let (num, rec) = seedlink::parse(&mut buf).unwrap();
            println!("{}: {}", num, rec);
            break;
        }
    }
    // Say Good bye
    slc.bye().expect("bad bye");
}

Documentation

https://docs.rs/seedlink/

Dependencies

~2.2–4MB
~87K SLoC