This is a Rust library that provides a way to interact with NNTP servers, compliant with RFC 3977 and RFC 4643.
Add the following to your Cargo.toml
:
toml
[dependencies]
rek2_nntp = "0.1.0" # Replace with the actual version
Run cargo build
to build the dependencies.
First, add the following import to your code:
rust
extern crate rek2_nntp;
To authenticate, use the authenticate
function:
```rust use rek2nntp::authenticate; use rek2nntp::AuthType;
// ... (connect to server and get a TcpStream)
authenticate(&mut stream, "host.com", "username", "password", AuthType::Plain).unwrap(); ```
To list newsgroups, use the list_newsgroups
function:
```rust use rek2nntp::listnewsgroups;
// ... (authenticate)
let newsgroups = list_newsgroups(&mut stream).unwrap(); ```
To read articles from a newsgroup:
```rust use rek2nntp::readfrom_group;
// ... (authenticate)
let articles = readfromgroup(&mut stream, "group.name", None).unwrap(); ```
To post an article to a newsgroup:
```rust use rek2nntp::postto_group;
// ... (authenticate)
let articledata = "Your article data here"; posttogroup(&mut stream, articledata).unwrap(); ```
Feel free to contribute to this project by creating issues, pull requests or improving the documentation.
This project is licensed under the GNU General Public License v3.0.