Expand description
A tiny ergonomic wrapper around WNetAddConnection2A
and WNetCancelConnection2A
. The goal is
to offer an easy to use interface to connect to SMB network shares on Windows.
Sam -> SMB -> Rust -> Samba is taken!? -> sambrs
§How To
Instantiate an SmbShare
with an optional local Windows mount point and establish a
connection.
When calling the connect method, you have the option to persist the connection across user
login sessions and to enable interactive mode. Interactive mode will block until the user
either provides a correct password or cancels, resulting in a Canceled
error.
use sambrs::SmbShare;
let share = SmbShare::new(r"\\server\share", "user", "pass", Some('D'));
match share.connect(false, false) {
Ok(()) => println!("Connected successfully!"),
Err(e) => eprintln!("Failed to connect: {}", e),
}
// use std::fs as if D:\ was a local directory
dbg!(std::fs::metadata(r"D:\").unwrap().is_dir());