#cross-platform #serialization #portable #virtual-fs

pfs

A portable, crass-platform, serializable representation of contained file system

3 unstable releases

Uses new Rust 2024

0.3.0 Jul 16, 2026
0.2.2 Jul 13, 2026
0.2.1 Jul 13, 2026
0.2.0 Nov 18, 2025

#2797 in Filesystem

MIT/Apache

99KB
2.5K SLoC

pfs

A portable, crass-platform, serializable representation of file system


lib.rs:

A portable, crass-platform, serializable reprentation of file system

A typical use for this crate is server sending file information to a client.

let mut pfs = PortableFs::without_cache("./".into());
pfs.allow_extension("toml");
let dir = pfs.read_dir(&Path::empty(), true).await.unwrap();
let toml_files = ["Cargo.toml", "rustfmt.toml"];
for entry in &dir.items {
    assert!(toml_files.contains(&entry.name.as_str()));
}
assert_eq!(dir.items.len(), toml_files.len());
println!("{}", serde_json::to_string_pretty(&dir).unwrap());

The output might look like

{
  "current_path": {
    "components": []
  },
  "items": [
    {
      "name": "Cargo.toml",
      "stats": {
        "size": 1581,
        "mtime": "2025-11-20T00:35:58.153Z",
        "is_directory": false,
        "sha256": "6e4c7f34b5956bbf053ae1f14b70c5cf02a748a1a6834c4bb915b1bc26ea3051"
      }
    },
    {
      "name": "rustfmt.toml",
      "stats": {
        "size": 102,
        "mtime": "2025-11-18T04:34:31.565Z",
        "is_directory": false,
        "sha256": "632059ea2fe5e8b96994e5529a96a981a68bf62cf1728c6f75be7f83439805b5"
      }
    }
  ]
}

Dependencies

~4–6MB
~100K SLoC