remotefs_ssh/lib.rs
1#![crate_name = "remotefs_ssh"]
2#![crate_type = "lib"]
3
4//! # remotefs-ssh
5//!
6//! remotefs-ssh is a client implementation for [remotefs](https://github.com/remotefs-rs/remotefs-rs), providing support for the SCP/SFTP protocols.
7//!
8//! ## Get started
9//!
10//! First of all you need to add **remotefs** and the client to your project dependencies:
11//!
12//! ```toml
13//! remotefs = "^0.3"
14//! remotefs-ssh = "^0.6"
15//! ```
16//!
17//! these features are supported:
18//!
19//! - `find`: enable `find()` method for RemoteFs. (*enabled by default*)
20//! - `no-log`: disable logging. By default, this library will log via the `log` crate.
21//!
22//!
23//! ### Ssh client
24//!
25//! Here is a basic usage example, with the `Sftp` client, which is very similiar to the `Scp` client.
26//!
27//! ```rust,ignore
28//!
29//! // import remotefs trait and client
30//! use remotefs::RemoteFs;
31//! use remotefs_ssh::{SshConfigParseRule, SftpFs, SshOpts};
32//! use std::path::Path;
33//!
34//! let mut client: SftpFs = SshOpts::new("127.0.0.1")
35//!     .port(22)
36//!     .username("test")
37//!     .password("password")
38//!     .config_file(Path::new("/home/cvisintin/.ssh/config"), ParseRule::STRICT)
39//!     .into();
40//!
41//! // connect
42//! assert!(client.connect().is_ok());
43//! // get working directory
44//! println!("Wrkdir: {}", client.pwd().ok().unwrap().display());
45//! // change working directory
46//! assert!(client.change_dir(Path::new("/tmp")).is_ok());
47//! // disconnect
48//! assert!(client.disconnect().is_ok());
49//! ```
50//!
51
52#![doc(html_playground_url = "https://play.rust-lang.org")]
53#![doc(
54    html_favicon_url = "https://raw.githubusercontent.com/remotefs-rs/remotefs-rs/main/assets/logo-128.png"
55)]
56#![doc(
57    html_logo_url = "https://raw.githubusercontent.com/remotefs-rs/remotefs-rs/main/assets/logo.png"
58)]
59
60// -- crates
61#[macro_use]
62extern crate lazy_regex;
63#[macro_use]
64extern crate log;
65
66mod ssh;
67pub use ssh::{
68    KeyMethod, MethodType, ParseRule as SshConfigParseRule, ScpFs, SftpFs, SshAgentIdentity,
69    SshKeyStorage, SshOpts,
70};
71
72// -- utils
73pub(crate) mod utils;
74// -- mock
75#[cfg(test)]
76pub(crate) mod mock;