5 releases

Uses old Rust 2015

0.0.5 Jun 27, 2017
0.0.4 Jan 11, 2016
0.0.3 Jun 7, 2015
0.0.2 Nov 26, 2014
0.0.1 Nov 24, 2014

#16 in #article

MIT/Apache

18KB
415 lines

rust-nntp

NNTP Client for Rust

Build Status

Usage

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("<cakj55F1dofU5@mid.individual.net>") {
		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();
}

License

MIT

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

No runtime deps