1个稳定版本
使用旧的Rust 2015
1.0.1 | 2017年10月18日 |
---|
#5 in #seismology
16KB
259 行
seedlink
SeedLink Library for rust
SeedLink是一种用于从可用服务器实时和准实时检索地震数据的协议
有关数据格式和协议的信息,请参见
- SeedLink: https://www.seiscomp3.org/wiki/doc/applications/seedlink
- MiniSEED: http://ds.iris.edu/ds/nodes/dmc/data/formats/miniseed/
- SEED: http://ds.iris.edu/ds/nodes/dmc/data/formats/seed/
用法
将以下内容添加到您的 Cargo.toml
[dependencies]
seedlink = "1.0.0"
并将其添加到您的crate根目录
extern crate seedlink;
您可能还需要包含miniseed crate;
示例
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");
}
文档
依赖
~2.3–4.5MB
~93K SLoC