MCPcopy Index your code
hub / github.com/SLMT/telnet-rs

github.com/SLMT/telnet-rs @v0.1.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.1.0 ↗ · + Follow
23 symbols 42 edges 5 files 9 documented · 39%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

telnet-rs

Build Status MIT licensed crates.io API docs

A simple Telnet implementation.

Examples

Blocking Reading

extern crate telnet;

use telnet::{Telnet, TelnetEvent};

fn main() {
    let mut telnet = Telnet::connect(("ptt.cc", 23), 256)
            .expect("Couldn't connect to the server...");

    loop {
        let event = telnet.read().expect("Read error");

        match event {
            TelnetEvent::Data(buffer) => {
                // Debug: print the data buffer
                println!("{:?}", buffer);
                // process the data buffer
            },
            _ => {}
        }
    }
}

Non-Blocking Reading

extern crate telnet;

use telnet::{Telnet, TelnetEvent};

fn main() {
    let mut telnet = Telnet::connect(("ptt.cc", 23), 256)
            .expect("Couldn't connect to the server...");

    loop {
        let event = telnet.read_nonblocking().expect("Read error");

        match event {
            TelnetEvent::Data(buffer) => {
                // Debug: print the data buffer
                println!("{:?}", buffer);
                // process the data buffer
            },
            _ => {}
        }

        // Do something else ...
    }
}

Writing

extern crate telnet;

use telnet::{Telnet};

fn main() {
    let mut telnet = Telnet::connect(("ptt.cc", 23), 256)
            .expect("Couldn't connect to the server...");

    let buffer: [u8; 4] = [83, 76, 77, 84];
    telnet.write(&buffer).expect("Read error");
}

TODOs

  • To reduce unnecessary data copy
  • To add coverage check
  • Add crate-level document

Core symbols most depended-on inside this repo

push_event
called by 9
src/event.rs
write
called by 4
src/lib.rs
append_data_to_proc_buffer
called by 4
src/lib.rs
process
called by 3
src/lib.rs
copy_buffered_data
called by 3
src/lib.rs
to_byte
called by 3
src/option.rs
take_event
called by 3
src/event.rs
is_empty
called by 3
src/event.rs

Shape

Method 17
Enum 4
Class 2

Languages

Rust100%

Modules by API surface

src/lib.rs12 symbols
src/event.rs6 symbols
src/option.rs3 symbols
src/negotiation.rs2 symbols

For agents

$ claude mcp add telnet-rs \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact