Skip to main content

smb_server/
lib.rs

1//! SMB2/3 file-sharing server with pluggable storage backends.
2//!
3//! Example:
4//!
5//! ```no_run
6//! use smb_server::{SmbServer, Share, Access, ShareBackend};
7//! # async fn run<B: ShareBackend>(backend: B) -> Result<(), Box<dyn std::error::Error>> {
8//! SmbServer::builder()
9//!     .listen("0.0.0.0:4445".parse()?)
10//!     .user("alice", "password")
11//!     .share(Share::new("home", backend).user("alice", Access::ReadWrite))
12//!     .build()?
13//!     .serve()
14//!     .await?;
15//! # Ok(()) }
16//! ```
17
18mod access_mask;
19mod backend;
20mod builder;
21pub(crate) mod conn;
22mod dispatch;
23mod error;
24#[cfg(feature = "localfs")]
25mod fs;
26mod handlers;
27pub(crate) mod info_class;
28pub mod ntstatus;
29mod path;
30mod proto;
31mod server;
32mod utils;
33
34pub use backend::{
35    BackendCapabilities, DirEntry, FileInfo, FileTimes, Handle, OpenIntent, OpenOptions,
36    ShareBackend,
37};
38pub use builder::{Access, BuildError, Share, SmbServerBuilder};
39pub use bytes::Bytes;
40pub use error::{SmbError, SmbResult};
41#[cfg(feature = "localfs")]
42pub use fs::LocalFsBackend;
43pub use path::SmbPath;
44pub use proto::auth::ntlm::Identity;
45pub use server::{ConfigError, ConfigHandle, ShareMode, ShutdownHandle, SmbServer};
46
47pub mod wire {
48    pub use crate::proto::header;
49    pub use crate::proto::messages;
50}
51
52#[cfg(test)]
53mod tests {
54    mod dynamic_config;
55    pub(crate) mod memfs;
56}