forked from mattnenterprise/rust-nntp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.rs
59 lines (51 loc) · 1.18 KB
/
example.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
extern crate nntp;
use nntp::{Article, NNTPStream};
fn main() {
let mut nntp_stream = match NNTPStream::connect(("nntp.aioe.org", 119)) {
Ok(stream) => stream,
Err(e) => panic!("{}", e)
};
match nntp_stream.capabilities() {
Ok(lines) => {
for line in lines.iter() {
print!("{}", line);
}
},
Err(e) => panic!(e)
}
match nntp_stream.list() {
Ok(groups) => {
for group in groups.iter() {
println!("Name: {}, High: {}, Low: {}, Status: {}", group.name, group.high, group.low, group.status)
}
},
Err(e) => panic!(e)
};
match nntp_stream.group("comp.sys.raspberry-pi") {
Ok(_) => (),
Err(e) => panic!(e)
}
match nntp_stream.article_by_number(6187) {
Ok(Article{headers, body}) => {
for (key, value) in headers.iter() {
println!("{}: {}", key, value)
}
for line in body.iter() {
print!("{}", line)
}
},
Err(e) => panic!(e)
}
match nntp_stream.article_by_id("<[email protected]>") {
Ok(Article{headers, body}) => {
for (key, value) in headers.iter() {
println!("{}: {}", key, value)
}
for line in body.iter() {
print!("{}", line)
}
},
Err(e) => panic!(e)
}
let _ = nntp_stream.quit();
}