Skip to content

Commit 8b3d42c

Browse files
authored
Add pre-commit checks, change packages metadata, and fix READMEs
- Additional docs updated - Stripped extra features from `tokio` - Add `std-fs-impls` feature to conditionally implement traits for File
1 parent 93537ad commit 8b3d42c

39 files changed

+256
-102
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ A clear and concise description of what the bug is.
1414
Contain a code snippet that uses the crate, and reproduces the bug.
1515

1616
**Desktop (please complete the following information):**
17-
- OS, architecture & version: [e.g. macOS 15.2, arm64]
18-
- Version [e.g. 0.8.1]
17+
18+
- OS, architecture & version: [e.g. macOS 15.2, arm64]
19+
- Version [e.g. 0.8.1]
1920

2021
**Additional context**
2122
Add any other context about the problem here.

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ env:
1414
jobs:
1515
test:
1616
runs-on: ubuntu-latest
17-
container:
17+
container:
1818
image: rustlang/rust:nightly
1919
timeout-minutes: 10
2020
strategy:
@@ -62,7 +62,7 @@ jobs:
6262
cargo test --verbose --no-default-features --features "${{ matrix.compile_features }},sign_hmac" -- --nocapture
6363
- name: Build/${{ matrix.compile_features }}
6464
run: cargo build --verbose --no-default-features --features "${{ matrix.compile_features }},${COMMON_FEATURES}"
65-
65+
6666
build-msrv:
6767
runs-on: ubuntu-latest
6868
container:

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
.DS_Store
33
.vscode
44
*.pcap
5-
.idea
5+
.idea

.markdownlint.jsonc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"line-length": false
3+
}

.pre-commit-config.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.6.0
4+
hooks:
5+
- id: end-of-file-fixer
6+
- id: trailing-whitespace
7+
28
- repo: local
39
hooks:
410
- id: rust-linting
@@ -16,3 +22,8 @@ repos:
1622
types: [file, rust]
1723
language: system
1824
verbose: true
25+
26+
- repo: https://github.com/DavidAnson/markdownlint-cli2
27+
rev: v0.13.0
28+
hooks:
29+
- id: markdownlint-cli2-docker

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ rand = "0.8.5"
2828
log = "0.4.22"
2929

3030
# Async
31-
tokio = { version = "1.43", features = ["full"] }
31+
tokio = { version = "1.43" }
3232
maybe-async = "0.2"
3333
futures-util = { version = "0.3" }
3434
futures-core = { version = "0.3" }

LICENSE.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
<!-- markdownlint-disable -->
2+
13
Copyright 2025 AVIV NAAMAN
24

35
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
46

57
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
68

7-
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,25 @@
44
[![Crates.io](https://img.shields.io/crates/v/smb)](https://crates.io/crates/smb)
55
[![docs.rs](https://img.shields.io/docsrs/smb/latest?link=https%3A%2F%2Fdocs.rs%2Fsmb%2Flatest%2Fsmb%2Findex.html)](https://docs.rs/smb/latest/smb/index.html)
66

7-
This project is the first rust implementation of [SMB2 & 3](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/5606ad47-5ee0-437a-817e-70c366052962) 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.
7+
This project is the first rust implementation of
8+
[SMB2 & 3](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/5606ad47-5ee0-437a-817e-70c366052962) client --
9+
the protocol that powers Windows file sharing and remote services.
10+
The project is designed to be used as a crate, but also includes a CLI tool for basic operations.
811

912
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!
1013

1114
## Getting started
15+
1216
Running the project's CLI is as simple as executing:
17+
1318
```sh
1419
cargo run -- --help
1520
```
21+
1622
Check out the `info` and the `copy` sub-commands for more information.
1723

18-
For advanced usage, and crate usage, see the [Advanced Usage](#advanced-usage) section.
1924
## Features
25+
2026
- ✅ SMB 2.X & 3.X support.
2127
- ✅ Async (`tokio`), Multi-threaded, or Single-threaded client.
2228
- ✅ Compression & Encryption support.
@@ -27,6 +33,7 @@ For advanced usage, and crate usage, see the [Advanced Usage](#advanced-usage) s
2733
You are welcome to see the project's roadmap in the [GitHub Project](https://github.com/users/AvivNaaman/projects/2).
2834

2935
## Using the crate
36+
3037
Check out the `Client` struct, exported from the `smb` crate, to initiate a connection to an SMB server:
3138

3239
```rust,no_run
@@ -37,11 +44,11 @@ use std::str::FromStr;
3744
async fn main() -> Result<(), Box<dyn std::error::Error>> {
3845
// instantiate the client
3946
let client = Client::new(ClientConfig::default());
40-
47+
4148
// Connect to a share
4249
let target_path = UncPath::from_str(r"\\server\share").unwrap();
4350
client.share_connect(&target_path, "username", "password".to_string()).await?;
44-
51+
4552
// And open a file on the server
4653
let file_to_open = target_path.with_path("file.txt");
4754
let file_open_args = FileCreateArgs::make_open_existing(FileAccessMask::new().with_generic_read(true));
@@ -61,8 +68,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
6168
Check out the [docs.rs](https://docs.rs/smb/latest/smb/index.html) for more information regarding usage.
6269

6370
## Development
71+
6472
To set up a development environment, you may use any supported rust version.
6573

66-
* It is highly recommended to use rust nightly, and install pre-commit hooks (using `pip install pre-commit && pre-commit install`)
67-
* Before committing your changes, run `cargo fmt` to format the code, and `cargo clippy` to check for linting issues.
68-
* Run crate tests once you are ready to commit. Read tests' README.md before proceeding!
74+
- It is highly recommended to use rust nightly, and install pre-commit hooks (using `pip install pre-commit && pre-commit install`)
75+
- Before committing your changes, run `cargo fmt` to format the code, and `cargo clippy` to check for linting issues.
76+
- Run crate tests once you are ready to commit. Read tests' README.md before proceeding!

crates/smb-cli/Cargo.toml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
[package]
22
name = "smb-cli"
3+
description = "SMB Command Line Interface using `smb-rs`"
4+
readme = "README.md"
35
version.workspace = true
46
edition.workspace = true
57
rust-version.workspace = true
68

79
[dependencies]
8-
smb = { path = "../smb", default-features = false }
10+
smb = { path = "../smb", default-features = false, features = ["std-fs-impls"] }
911

1012
maybe-async = { workspace = true }
11-
tokio = { workspace = true, optional = true }
13+
tokio = { workspace = true, optional = true, features = ["rt-multi-thread"] }
1214
futures-util = { workspace = true, optional = true }
1315

1416
# CLI & logging
@@ -18,15 +20,11 @@ env_logger = "0.11.6"
1820
log = { workspace = true }
1921

2022
[features]
21-
default = ["async", "smb/default"]
23+
default = ["async"]
2224

23-
async = ["smb/async", "dep:tokio", "dep:futures-util"]
24-
single_threaded = ["smb/single_threaded", "maybe-async/is_sync"]
25-
multi_threaded = ["smb/multi_threaded", "maybe-async/is_sync"]
26-
27-
sign = ["smb/sign"]
28-
encrypt = ["smb/encrypt"]
29-
compress = ["smb/compress"]
25+
async = ["dep:tokio", "dep:futures-util"]
26+
single_threaded = ["maybe-async/is_sync"]
27+
multi_threaded = ["maybe-async/is_sync"]
3028

3129
quic = ["smb/quic"]
3230
rdma = ["smb/rdma"]

crates/smb-cli/README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
11
# SMB-CLI
2+
23
this is a sample-ish program that uses the `smb` crate to build a command line utility.
4+
35
## Usage
6+
47
```sh
58
cargo run -- --help
69
```
10+
711
Check out the subcommands `info` and `copy` for more details.
12+
813
## Profiling
14+
915
From the project's root, build with:
16+
1017
```sh
1118
cargo build --profile profiling --features profiling
1219
```
20+
1321
### macOS
22+
1423
- Build the program as described above.
1524
- Install `instruments` from Xcode.
1625
- Launch the program from command line.
1726
- Open `instruments` and attach, using the right profiler.
1827
- Enter in the command line to actually begin the execution of the program.
1928

2029
>[!note]
21-
> Launching the program from within `instruments` doesn't work properly, since local network connections are blocked. This also happens when using `lldb` to attach to the process. The program must be launched from the command line, and then `instruments` can attach to it.
30+
> Launching the program from within `instruments` doesn't work properly, since local network connections are blocked. This also happens when using `lldb` to attach to the process. The program must be launched from the command line, and then `instruments` can attach to it.

0 commit comments

Comments
 (0)