| Crates.io | smb |
| lib.rs | smb |
| version | 0.9.0 |
| created_at | 2025-02-07 15:15:17.207838+00 |
| updated_at | 2025-09-06 16:22:29.441005+00 |
| description | A Pure Rust SMB Client implementation |
| homepage | |
| repository | https://github.com/AvivNaaman/smb-rs |
| max_upload_size | |
| id | 1547055 |
| size | 932,452 |
This project is the first rust implementation of SMB2 & 3 client -- the protocol that powers Windows file sharing and remote services. The project is designed to be used as a crate, but also includes a CLI tool for basic operations.
While most current implementations are mostly bindings to C libraries (such as libsmb2, samba, or windows' own libraries), this project is a full implementation in Rust, with no dependencies on C libraries!
Running the project's CLI is as simple as executing:
cargo run -- --help
Check out the info and the copy sub-commands for more information.
For advanced usage, and crate usage, see the Advanced Usage section.
tokio), Multi-threaded, or Single-threaded client.sspi crate).You are welcome to see the project's roadmap in the GitHub Project.
Check out the Client struct, exported from the smb crate, to initiate a connection to an SMB server:
use smb::{Client, ClientConfig, UncPath, FileCreateArgs, FileAccessMask, ReadAt};
use std::str::FromStr;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// instantiate the client
let client = Client::new(ClientConfig::default());
// Connect to a share
let target_path = UncPath::from_str(r"\\server\share").unwrap();
client.share_connect(&target_path, "username", "password".to_string()).await?;
// And open a file on the server
let file_to_open = target_path.with_path("file.txt");
let file_open_args = FileCreateArgs::make_open_existing(FileAccessMask::new().with_generic_read(true));
let resource = client.create_file(&file_to_open, &file_open_args).await?;
// now, you can do a bunch of operations against `file`, and close it at the end.
let file = resource.unwrap_file();
let mut data: [u8; 1024] = [0; 1024];
file.read_at(&mut data, 0).await?;
// and close
file.close().await?;
Ok(())
}
Check out the docs.rs for more information regarding usage.
To set up a development environment, you may use any supported rust version.
pip install pre-commit && pre-commit install)cargo fmt to format the code, and cargo clippy to check for linting issues.