Skip to main content

Crate smb2

Crate smb2 

Source
Expand description

Pure-Rust SMB2/3 client library with pipelined I/O.

No C dependencies, no FFI. Pipelined reads/writes fill the credit window so downloads run ~10-25x faster than sequential SMB clients.

§Quick start

use smb2::{SmbClient, ClientConfig};

let mut client = smb2::connect("192.168.1.100:445", "user", "pass").await?;

// List shares
let shares = client.list_shares().await?;

// Connect to a share
let mut share = client.connect_share("Documents").await?;

// List files
let entries = client.list_directory(&mut share, "projects/").await?;
for entry in &entries {
    println!("{} ({} bytes)", entry.name, entry.size);
}

// Read a file
let data = client.read_file(&mut share, "report.pdf").await?;

§Modules

  • client – High-level API: SmbClient, Tree, Pipeline. This is what most users need.
  • error – Error types and NTSTATUS mapping.
  • msg – Wire format message structs (advanced/internal use).
  • pack – Binary serialization primitives (advanced/internal use).
  • transport – Transport trait and TCP implementation (advanced/internal use).
  • crypto – Signing and encryption (advanced/internal use).
  • auth – NTLM authentication (advanced/internal use).
  • rpc – Named pipe RPC for share enumeration (advanced/internal use).
  • types – Protocol newtypes and flag types (advanced/internal use).

Re-exports§

pub use error::Error;
pub use error::ErrorKind;
pub use error::Result;
pub use client::connect;
pub use client::ClientConfig;
pub use client::SmbClient;
pub use client::stream::FileDownload;
pub use client::stream::FileUpload;
pub use client::stream::FileWriter;
pub use client::stream::Progress;
pub use client::tree::DirectoryEntry;
pub use client::tree::FileInfo;
pub use client::tree::FsInfo;
pub use client::tree::Tree;
pub use client::pipeline::Op;
pub use client::pipeline::OpResult;
pub use client::pipeline::Pipeline;
pub use client::connection::CompoundOp;
pub use client::connection::Frame;
pub use client::connection::NegotiatedParams;
pub use client::session::Session;
pub use client::watcher::FileNotifyAction;
pub use client::watcher::FileNotifyEvent;
pub use client::watcher::Watcher;
pub use rpc::srvsvc::ShareInfo;
pub use auth::kerberos::KerberosAuthenticator;
pub use auth::kerberos::KerberosCredentials;

Modules§

auth
Authentication mechanisms for SMB2.
client
High-level SMB2 client API.
crypto
Cryptographic operations for SMB2/3: signing, encryption, key derivation, and compression.
error
Error types for the SMB2 library.
fuzzing
Fuzzing entry points for fuzz/ targets.
msg
Wire format message structs for SMB2/3.
pack
Binary serialization/deserialization primitives for SMB2.
rpc
Named pipe RPC (MS-RPCE / NDR) for share enumeration.
testing
Docker-based SMB test servers for integration testing.
transport
Transport abstraction for sending and receiving SMB2 messages.
types
Newtypes, enums, and common data structures for SMB2/3 protocol fields.