#telnet #mud #libtelnet

libtelnet-rs

libtelnet-inspired telnet parser for rust

18 releases (5 stable)

2.0.0 Sep 17, 2021
1.1.2 Nov 1, 2020
1.1.1 Oct 29, 2020
0.3.9 Jun 9, 2020

#776 in Network programming

Download history 103/week @ 2023-10-20 149/week @ 2023-10-27 156/week @ 2023-11-03 167/week @ 2023-11-10 80/week @ 2023-11-17 28/week @ 2023-11-24 84/week @ 2023-12-01 31/week @ 2023-12-08 33/week @ 2023-12-15 65/week @ 2023-12-22 7/week @ 2023-12-29 11/week @ 2024-01-05 11/week @ 2024-01-12 29/week @ 2024-01-19 29/week @ 2024-01-26 25/week @ 2024-02-02

96 downloads per month

MIT license

38KB
828 lines

Rust Crates.io Docs.rs

libtelnet-rs

libtelnet-inspired telnet parser for rust.

Documentation

BREAKING CHANGES

As of version 2.0, I have switched over to using the bytes crate.

With this change, the method signatures for most methods that return Vec<u8> now return Bytes instead.

For most situations where a Vec<u8> would be required, the returned value can simply be changed to utilize Bytes::to_vec().

To make usage of the new dependency a little bit easier, it is also re-exported as libtelnet_rs::bytes.

Usage

Check src/tests.rs for an example parser.

Ideally, you would place this parser somewhere directly behind a socket or external source of data.

When data comes in from the socket, immediately send it into the parser with parser.receive(data).

This will append it to the current internal buffer, and then process any events that are in the buffer.

After processing, all telnet events will be returned by parser.receive() and can be looped over and handled as needed.

Anything to be sent back over the socket to the remote end should be sent through the parser as well, to ensure any data will be encoded properly for the telnet protocol.

Data to be sent will be provided either by a events::TelnetEvents::DataSend event after processing, or as a return from any method used for sending data.

Dependencies

~165KB