remotefs_smb/
lib.rs

1#![crate_name = "remotefs_smb"]
2#![crate_type = "lib"]
3
4//! # remotefs-smb
5//!
6//! remotefs-smb is a client implementation for [remotefs](https://github.com/remotefs-rs/remotefs-rs), providing support for the SMB protocol.
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-smb = "^0.3"
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//! ### Smb client (UNIX)
24//!
25//! Here is a basic usage example, with the `Smb` client.
26//!
27//! ```rust
28//!
29//! // import remotefs trait and client
30//! use remotefs::{RemoteFs, fs::UnixPex};
31//! use remotefs_smb::{SmbFs, SmbOptions, SmbCredentials};
32//! use std::path::Path;
33//!
34//! let mut client = SmbFs::try_new(
35//!     SmbCredentials::default()
36//!         .server("smb://localhost:3445")
37//!         .share("/temp")
38//!         .username("test")
39//!         .password("test")
40//!         .workgroup("pavao"),
41//!     SmbOptions::default()
42//!         .case_sensitive(true)
43//!         .one_share_per_server(true),
44//! )
45//! .unwrap();
46//!
47//! // connect
48//! assert!(client.connect().is_ok());
49//! // get working directory
50//! println!("Wrkdir: {}", client.pwd().ok().unwrap().display());
51//! // make directory
52//! assert!(client.create_dir(Path::new("/cargo"), UnixPex::from(0o755)).is_ok());
53//! // change working directory
54//! assert!(client.change_dir(Path::new("/cargo")).is_ok());
55//! // disconnect
56//! assert!(client.disconnect().is_ok());
57//! ```
58//!
59
60#![doc(html_playground_url = "https://play.rust-lang.org")]
61#![doc(
62    html_favicon_url = "https://raw.githubusercontent.com/remotefs-rs/remotefs-rs/main/assets/logo-128.png"
63)]
64#![doc(
65    html_logo_url = "https://raw.githubusercontent.com/remotefs-rs/remotefs-rs/main/assets/logo.png"
66)]
67
68// -- crates
69#[macro_use]
70extern crate log;
71
72mod client;
73
74#[cfg(target_family = "unix")]
75pub use client::{SmbCredentials, SmbEncryptionLevel, SmbFs, SmbOptions, SmbShareMode};
76#[cfg(target_family = "windows")]
77pub use client::{SmbCredentials, SmbFs};
78
79// -- utils
80#[cfg(target_family = "unix")]
81pub(crate) mod utils;
82// -- mock
83#[cfg(test)]
84pub(crate) mod mock;