librust_winrm/lib.rs
1//! # librust-winrm
2//!
3//! A WinRM (Windows Remote Management) client library for Rust.
4//!
5//! ## Features
6//!
7//! - **NTLM Authentication**: Full support for NTLM authentication over HTTPS
8//! - **Command Execution**: Execute commands and PowerShell scripts remotely
9//! - **File Transfer**: Upload and download files to/from remote Windows systems
10//! - **Error Handling**: Comprehensive error types with context
11//!
12//! ## Example
13//!
14//! ```no_run
15//! use librust_winrm::WinRMClient;
16//!
17//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
18//! let mut client = WinRMClient::new(
19//! "https://10.0.3.203:5986/wsman",
20//! "administrator",
21//! "password",
22//! "ntlm",
23//! true, // insecure (skip SSL verification)
24//! None, // CA cert path
25//! )?;
26//!
27//! // Open shell
28//! let shell_id = client.open_shell()?;
29//!
30//! // Run command
31//! let command_id = client.run_command(&shell_id, "whoami")?;
32//!
33//! // Get output
34//! let (stdout, stderr, exit_code) = client.get_command_output(&shell_id, &command_id)?;
35//! println!("Output: {}", stdout);
36//!
37//! // Close shell
38//! client.close_shell(&shell_id)?;
39//! # Ok(())
40//! # }
41//! ```
42//!
43//! ## File Transfer Example
44//!
45//! ```no_run
46//! use librust_winrm::{WinRMClient, upload_file, download_file};
47//!
48//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
49//! let mut client = WinRMClient::new(
50//! "https://server:5986/wsman",
51//! "admin",
52//! "pass",
53//! "ntlm",
54//! false,
55//! None,
56//! )?;
57//!
58//! let shell_id = client.open_shell()?;
59//!
60//! // Upload
61//! upload_file(&mut client, &shell_id, "local.txt", "C:\\\\remote.txt")?;
62//!
63//! // Download
64//! download_file(&mut client, &shell_id, "C:\\\\file.txt", "./local.txt")?;
65//!
66//! client.close_shell(&shell_id)?;
67//! # Ok(())
68//! # }
69//! ```
70
71mod client;
72mod error;
73mod ops;
74mod xml;
75
76pub use client::WinRMClient;
77pub use error::WinRMError;
78pub use ops::{upload_file, download_file};
79
80/// Re-export of Result type for convenience
81pub type Result<T> = std::result::Result<T, anyhow::Error>;