NNTP client for Rust

Overview

rust-nntp

NNTP Client for Rust

Build Status crates.io

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("<[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();
}

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.

Comments
  • Subcratify

    Subcratify

    Enormous, disruptive rename so we can have multiple crates. For now:

    • nntp-client: all the things required to talk to a remote server
    • nntp-indexer: application for taking groups and putting them in to Elasticsearch
    opened by xrl 1
  • Use Bufstream

    Use Bufstream

    The project does a lot of small reads in order to look for terminal characters. This code does two things to make that more efficient:

    • bufstream: performs big reads to possibly reduce number of kernel calls (bufstream manages the large underlying buffer)
    • NNTPLines: a rewrite of the stdlib's Lines trait, it handles finding terminal characters so we can just iterate over the lines.

    Pretty big change to the library but it should reduce memory pressure and make things snappier at scale.

    opened by xrl 1
  • Relicense under dual MIT/Apache-2.0

    Relicense under dual MIT/Apache-2.0

    This issue was automatically generated. Feel free to close without ceremony if you do not agree with re-licensing or if it is not possible for other reasons. Respond to @cmr with any questions or concerns, or pop over to #rust-offtopic on IRC to discuss.

    You're receiving this because someone (perhaps the project maintainer) published a crates.io package with the license as "MIT" xor "Apache-2.0" and the repository field pointing here.

    TL;DR the Rust ecosystem is largely Apache-2.0. Being available under that license is good for interoperation. The MIT license as an add-on can be nice for GPLv2 projects to use your code.

    Why?

    The MIT license requires reproducing countless copies of the same copyright header with different names in the copyright field, for every MIT library in use. The Apache license does not have this drawback. However, this is not the primary motivation for me creating these issues. The Apache license also has protections from patent trolls and an explicit contribution licensing clause. However, the Apache license is incompatible with GPLv2. This is why Rust is dual-licensed as MIT/Apache (the "primary" license being Apache, MIT only for GPLv2 compat), and doing so would be wise for this project. This also makes this crate suitable for inclusion and unrestricted sharing in the Rust standard distribution and other projects using dual MIT/Apache, such as my personal ulterior motive, the Robigalia project.

    Some ask, "Does this really apply to binary redistributions? Does MIT really require reproducing the whole thing?" I'm not a lawyer, and I can't give legal advice, but some Google Android apps include open source attributions using this interpretation. Others also agree with it. But, again, the copyright notice redistribution is not the primary motivation for the dual-licensing. It's stronger protections to licensees and better interoperation with the wider Rust ecosystem.

    How?

    To do this, get explicit approval from each contributor of copyrightable work (as not all contributions qualify for copyright, due to not being a "creative work", e.g. a typo fix) and then add the following to your README:

    ## License
    
    Licensed under either of
    
     * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
     * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
    
    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.
    

    and in your license headers, if you have them, use the following boilerplate (based on that used in Rust):

    // Copyright 2016 rust-nntp Developers
    //
    // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
    // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
    // http://opensource.org/licenses/MIT>, at your option. This file may not be
    // copied, modified, or distributed except according to those terms.
    

    It's commonly asked whether license headers are required. I'm not comfortable making an official recommendation either way, but the Apache license recommends it in their appendix on how to use the license.

    Be sure to add the relevant LICENSE-{MIT,APACHE} files. You can copy these from the Rust repo for a plain-text version.

    And don't forget to update the license metadata in your Cargo.toml to:

    license = "MIT OR Apache-2.0"
    

    I'll be going through projects which agree to be relicensed and have approval by the necessary contributors and doing this changes, so feel free to leave the heavy lifting to me!

    Contributor checkoff

    To agree to relicensing, comment with :

    I license past and future contributions under the dual MIT/Apache-2.0 license, allowing licensees to chose either at their option.
    

    Or, if you're a contributor, you can check the box in this repo next to your name. My scripts will pick this exact phrase up and check your checkbox, but I'll come through and manually review this issue later as well.

    • [x] @mattnenterprise
    opened by emberian 1
  • Some TLC for the crate

    Some TLC for the crate

    • Convert writes to byte slices
    • Replace pervasive matches with ?
    • Use Result::map operator for conversions
    • Reformat with "cargo +stable fmt"

    Awesome crate btw! I wanted to learn more about the NNTP protocol and this is the easiest reference I have found.

    opened by xrl 0
  • Relicense to dual MIT/Apache-2.0

    Relicense to dual MIT/Apache-2.0

    This pull request was automatically generated because my scripts detected that everyone in the relicensing issue agreed to relicensing.

    License headers in files were not updated, if they exist. I've reproduced an example license header below if you want to copy-paste it in. If you don't have license headers, don't feel compelled to add them.

    // Copyright 2016 rust-nntp Developers
    //
    // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
    // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
    // http://opensource.org/licenses/MIT>, at your option. This file may not be
    // copied, modified, or distributed except according to those terms.
    

    I recommend publishing a new patch version (the z in x.y.z) so that the metadata propagates to crates.io.

    Please be sure to check the README.md for style. I've try to review these PRs as they go out, but I might miss something.

    Thanks for relicensing!

    (For my bookkeeping: this is repository id rust-nntp-efbb4f34-c501-4987-8a54-a3c5e396b5e8)

    opened by emberian 0
  • Changes while I wrote an indexer

    Changes while I wrote an indexer

    I was experimenting with this library to build an indexer.

    • Async support
    • Buffered IO
    • TLS support
    • Trying to work out how to pipeline requests
    • Github actions for tests
    • Indexer example which works against an Elasticsearch cluster (see the docker-compose)

    I've just been merging in to my master branch so it's a big ball of changes. But I wanted to float this past you so you could see how all this is coming together.

    I couldn't figure out how to recombobulate binary groups to make sense of articles so this work just kind of came to a pause

    opened by xrl 0
  • Handle non-UTF8 data

    Handle non-UTF8 data

    I'd like to start reading some binary newsgroups and I'm finding that the code breaks because it assumes all strings are UTF8. We should use Vec to model the incoming data.

    opened by xrl 2
  • Implement server for rust-nntp

    Implement server for rust-nntp

    Hi,

    I was wondering if it would be a viable idea to implement a server into rust-nntp, a bit like the irc crate for Rust, which has both client and server capabilities.

    WDYT?

    opened by shymega 1
Owner
Matt McCoy
Matt McCoy
FTP client for Rust

rust-ftp FTP client for Rust Documentation rust-ftp Installation Usage License Contribution Development environment Installation FTPS support is achie

Matt McCoy 155 Nov 12, 2022
POP3 client for Rust

rust-pop3 POP3 Client for Rust This client has SSL support. SSL is configured using an SSLContext that is passed into the connect method of a POP3Stre

Matt McCoy 26 Dec 19, 2022
A STOMP client in Rust. Compatible with RabbitMQ, ActiveMQ.

stomp-rs stomp-rs provides a full STOMP 1.2 client implementation for the Rust programming language. This allows programs written in Rust to interact

Zack Slayton 84 Dec 4, 2022
Rust client for NATS, the cloud native messaging system.

A Rust client for the NATS messaging system. Status Motivation Rust may be the most interesting new language the NATS ecosystem has seen. We believe t

NATS - The Cloud Native Messaging System 651 Jan 3, 2023
rqbit - bittorrent client in Rust

rqbit - bittorrent client in Rust

Igor Katson 177 Jan 2, 2023
Simple project to test grpc between ruby (client) and rust (server)

grpc-example Simple project to test grpc between ruby (client) and rust (server). Usage To simplify a lot this project uses docker and docker compose

Bruno Arueira 2 Oct 14, 2021
A rust client and structures to interact with the Clever-Cloud API.

Clever-Cloud Software Development Kit - Rust edition This crate provides structures and client to interact with the Clever-Cloud API. Status This crat

Clever Cloud 6 Jun 3, 2022
Third party Google DNS client for rust.

google-dns-rs Documentation Install Add the following line to your Cargo.toml file: google-dns-rs = "0.3.0" Usage use google_dns_rs::api::{Dns, DoH, R

Eduardo Stuart 2 Nov 13, 2021
A ddns client written in Rust.

ddns-rs ready for use with one cloudflare A/AAAA record ?? A ddns client written in Rust. Features get public ip cloudflare (A or AAAA record) toml co

Ric Li 1 Oct 25, 2022
Rust client for apache iotdb.

Apache IoTDB Apache IoTDB (Database for Internet of Things) is an IoT native database with high performance for data management and analysis, deployab

Mark Liu 7 Aug 4, 2022
Rust client for Kubernetes

Rust client for Kubernetes API.

null 244 Dec 17, 2022
A Rust based DNS client, server, and resolver

Trust-DNS A Rust based DNS client, server, and Resolver, built to be safe and secure from the ground up. This repo consists of multiple crates: Librar

Benjamin Fry 2.7k Dec 30, 2022
An online version of the popular game four in a row, written in Rust on the server side and Flutter + Dart on the client.

Four in a Row - Server An online version of the popular game four in a row, written in Rust on the server side and Flutter + Dart on the client. Downl

Filippo OrrĂ¹ 8 Sep 16, 2022
A minimalist socket-based client/server in Rust to illustrate a tutorial

The basics of unix sockets This repository serves as a reference for this tutorial blogpost How to run Install Rust and Cargo, and then do: cargo run

Emmanuel Bosquet 4 Dec 4, 2022
Rust Verbio SpeechCenter Client

The CLI client allows you to launch a single file to the server. It also allows you to use either a grammar or a language model.

Verbio Technologies 3 Sep 16, 2022
Fast Discord RPC Client written in Rust

Discord RPC Client Examples Big image, small image, details and one button discordrpc -c 942151169185316874 -d 'untypeable nickname' --button-1-text '

Oskar 10 Jan 1, 2023
Rust client for Apache Kafka

Kafka Rust Client Project Status This project is starting to be maintained by John Ward, the current status is that I am bringing the project up to da

Kafka Rust 900 Dec 26, 2022
This is a UPnP client library for Rust.

UPnP Client This is a UPNP client library for Rust. Usage Add this to your Cargo.toml: [dependencies] upnp-client = "0.1" Example This example will pr

Tsiry Sandratraina 7 Feb 20, 2023
Socket.io client written in Rust

Rust-socketio-client An implementation of a socket.io client written in the rust programming language. This implementation currently supports revision

Hand of Midas 4 May 9, 2023