rneter/lib.rs
1//! # rneter - Network Device SSH Connection Manager
2//!
3//! `rneter` is a Rust library for managing SSH connections to network devices with
4//! intelligent state machine handling. It provides a high-level API for connecting to
5//! network devices (routers, switches, etc.), executing commands, and managing device
6//! states with automatic prompt detection and mode switching.
7//!
8//! ## Features
9//!
10//! - **Connection Pooling**: Automatically caches and reuses SSH connections
11//! - **State Machine Management**: Intelligent device state tracking and transitions
12//! - **Prompt Detection**: Automatic prompt recognition and handling
13//! - **Mode Switching**: Seamless transitions between device modes (user mode, enable mode, config mode, etc.)
14//! - **Maximum Compatibility**: Supports a wide range of SSH algorithms for compatibility with legacy devices
15//! - **Async/Await**: Built on Tokio for high-performance asynchronous operations
16//!
17//! ## Quick Start
18//!
19//! ```rust,no_run
20//! use rneter::session::{MANAGER, Command, CmdJob};
21//! use rneter::templates;
22//!
23//! #[tokio::main]
24//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
25//! // Use a predefined device template (e.g., Cisco)
26//! let handler = templates::cisco();
27//!
28//! // Get a connection from the manager
29//! let sender = MANAGER.get(
30//! "admin".to_string(),
31//! "192.168.1.1".to_string(),
32//! 22,
33//! "password".to_string(),
34//! None,
35//! handler,
36//! ).await?;
37//!
38//! // Execute a command
39//! let (tx, rx) = tokio::sync::oneshot::channel();
40//! let cmd = CmdJob {
41//! data: Command {
42//! mode: "Enable".to_string(), // Cisco template uses "Enable" mode
43//! command: "show version".to_string(),
44//! timeout: Some(60),
45//! },
46//! sys: None,
47//! responder: tx,
48//! };
49//!
50//! sender.send(cmd).await?;
51//! let output = rx.await??;
52//!
53//! println!("Command output: {}", output.content);
54//! Ok(())
55//! }
56//! ```
57//!
58//! ## Main Components
59//!
60//! - [`session::SshConnectionManager`] - Manages SSH connection pool and lifecycle
61//! - [`device::DeviceHandler`] - Handles device state machine and transitions
62//! - [`error::ConnectError`] - Error types for connection and state operations
63//! - [`config`] - SSH configuration constants
64//! - [`templates`] - Predefined device configurations for common vendors for maximum compatibility
65
66pub mod config;
67pub mod device;
68pub mod error;
69pub mod session;
70pub mod templates;