Crates.io | seedlink |
lib.rs | seedlink |
version | 1.0.1 |
source | src |
created_at | 2017-10-18 22:40:30.458229 |
updated_at | 2017-10-18 22:40:30.458229 |
description | SeedLink library for rust |
homepage | https://github.com/savage13/seedlink |
repository | https://github.com/savage13/seedlink |
max_upload_size | |
id | 36139 |
size | 23,550 |
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:
SeedLink: https://www.seiscomp3.org/wiki/doc/applications/seedlink
MiniSEED: http://ds.iris.edu/ds/nodes/dmc/data/formats/miniseed/
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;
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");
}