camino-rs / camino

Like Rust's std::path::Path, but UTF-8.
https://docs.rs/camino
Apache License 2.0
435 stars 16 forks source link

Add (optional, feature-gated) proptest::Arbitrary implementation #18

Closed mcronce closed 2 years ago

mcronce commented 2 years ago

This makes it easier to proptest code that makes use of camino

sunshowers commented 2 years ago

Thanks -- I think I'm going to land this and then iterate on it locally.

sunshowers commented 2 years ago

This is out as part of camino 1.0.8 and above (just released 1.0.9 with some documentation fixes).

mcronce commented 2 years ago

Awesome. Thanks!

Just to provide a little extra flavor about my use case, I'm using proptest to validate parsing/reserializing SFTP packets in https://gitlab.cronce.io/foss/sftp-rs/-/tree/master/sftp-protocol/src/packet - technically any valid UTF-8 string is a valid path, as nonsensical as it might be (e.g. the string "LeɬXYVº5Þ=7Ԏ!ŚϔO" could very well be referring to a file named LeɬXYVº5Þ=7Ԏ!ŚϔO in the current working directory...so the parser needs to correctly handle that case)

In particular, paths in SFTP are specified to be UTF-8 unless a protocol extension says otherwise. I'm taking an opinionated stance and not supporting any protocol extensions of that nature :)