Files
markbase/vendor/smb2/src/lib.rs
Warren 7eb528d35f
Some checks failed
Test / build (push) Has been cancelled
Test / test (push) Has been cancelled
SMB Server Phase 2: VFS backend build fix + integration test
- Add VfsFile: Send supertrait for Mutex compatibility
- Fix SmbServerCommand: struct → Subcommand enum with Start variant
- Fix tracing_subscriber::init() → try_init() to avoid panic when
  logger already initialized
- Fix CLI subcommand name: smb-server → smb-start (flatten naming)
- Add #[command(name = "smb-start")] for CLI disambiguation
- Fix unused variable warnings (smb_fs.rs, smb_server_backend.rs)
- Remove unused VfsFile imports (webdav.rs, scp_handler.rs)
- Integration test: Docker smbclient verified (list, upload, read)
2026-06-20 19:42:29 +08:00

100 lines
3.1 KiB
Rust

#![forbid(unsafe_code)]
#![warn(missing_docs)]
//! 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
//!
//! ```rust,no_run
//! use smb2::{SmbClient, ClientConfig};
//!
//! # async fn example() -> Result<(), smb2::Error> {
//! 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?;
//! # Ok(())
//! # }
//! ```
//!
//! # 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).
pub mod auth;
pub mod client;
pub mod crypto;
pub mod error;
pub mod msg;
pub mod pack;
pub mod rpc;
#[cfg(feature = "testing")]
pub mod testing;
pub mod transport;
pub mod types;
#[cfg(feature = "fuzzing")]
pub mod fuzzing;
// ── Re-exports: the simple-case imports ────────────────────────────────
// Error types
pub use error::{Error, ErrorKind, Result};
// High-level client
pub use client::{connect, ClientConfig, SmbClient};
// Streaming I/O
pub use client::stream::{FileDownload, FileUpload, FileWriter, Progress};
// Tree and file types
pub use client::tree::{DirectoryEntry, FileInfo, FsInfo, Tree};
// Pipeline
pub use client::pipeline::{Op, OpResult, Pipeline};
// Connection-level types (useful for advanced users)
pub use client::connection::{CompoundOp, Frame, NegotiatedParams};
pub use client::session::Session;
// Diagnostics: snapshot tree returned by `SmbClient::diagnostics()` /
// `Connection::diagnostics()`.
pub use client::diagnostics::{
ClientInfo, ClientMetricsSnapshot, CompressionInfo, ConnectionDiagnostics, CreditInfo,
DfsCacheEntry, Diagnostics, EncryptionInfo, MetricsSnapshot, NegotiatedSummary,
SessionDiagnostics, SigningInfo,
};
// File watching
pub use client::watcher::{FileNotifyAction, FileNotifyEvent, Watcher};
// Share enumeration
pub use rpc::srvsvc::ShareInfo;
// Kerberos authentication
pub use auth::kerberos::{KerberosAuthenticator, KerberosCredentials};