How it works...
By using Rust's ability to run sub-processes and manipulate their inputs and outputs, it's easy to integrate existing applications into the new program's workflow. In step 1, we do exactly that by using the find program with parameters and parse the output into our own data structure.
In step 3, we go further and send data into a sub-process and recover the same text (using cat in an echo-like fashion). You'll notice the parsing of a string in each function, which is required as Windows and Linux/macOS use different byte sizes to encode their characters (UTF-16 and UTF-8 respectively). Similarly, the b"string" transforms the literal into a byte-literal appropriate for the current platform.
The key ingredient for these operations ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access