`dust` is a very fast implementation of `du` in Rust.
How it's implemented?
## Concurrency
[Rayon](https://crates.io/crates/rayon) is used for parallelism.
- [Import rayon](https://github.com/bootandy/dust/blob/dd799706fbd062b468d5e8e219c0ef332344588b/src/dir_walker.rs#L15)
```rust title="dur_walker"
use rayon::iter::ParallelBridge;
use rayon::prelude::ParallelIterator;
```
- [Iterate through dirs with rayon](https://github.com/bootandy/dust/blob/dd799706fbd062b468d5e8e219c0ef332344588b/src/dir_walker.rs#L219)
```rust
let children = if dir.is_dir() {
let read_dir = fs::read_dir(&dir);
match read_dir {
Ok(entries) => {
entries
.into_iter()
.par_bridge()
.filter_map(|entry| {
match entry {
...
```
## Get File Metadata
- [get_metadata](https://github.com/bootandy/dust/blob/dd799706fbd062b468d5e8e219c0ef332344588b/src/platform.rs#L17) function supports apparent size
Apparent size is obtained from `metadata.len()`, the other option is computed with `metadata.blocks() * block_size`.
## Avoid Double Count
Links could result in circular recursive search. `inode` is used to prevent this.
[`clean_inodes`](https://github.com/bootandy/dust/blob/dd799706fbd062b468d5e8e219c0ef332344588b/src/dir_walker.rs#L149) called recursively on a node tree to remove existing children, identified by `inodes`.