| Crates.io | path_as_uri |
| lib.rs | path_as_uri |
| version | 0.1.0 |
| created_at | 2025-04-20 13:00:46.841738+00 |
| updated_at | 2025-04-20 13:00:46.841738+00 |
| description | Convert a path to a URI |
| homepage | |
| repository | https://github.com/Alirex/rs_lib_i_path_as_uri |
| max_upload_size | |
| id | 1641682 |
| size | 23,850 |
Allows you to get the path of a file as a URI. That can be clicked in the terminal.
use path_as_uri::get_path_as_uri_string;
fn main() {
let path = std::path::PathBuf::new("/path/to/file.txt");
let uri = get_path_as_uri_string(&path);
println!("URI: {}", uri);
}
In some apps, I want to provide a clickable path to a file in the terminal from the app.
Uri is a working solution for this.
In Python, you can make a similar solution using pathlib module:
I'm tired of some repeatable boilerplate code. I just want to call the function and get the result. In different small apps.
So I created this library.
For now, it is a relatively simple wrapper around url library.
Yes, you can try to concatenate your path with file:// prefix.
But it will not work for all cases.
For example, if you have a path with spaces in it, you need to encode it.
So, for me, it is easier to use a library that does it for me.
pre-commit install
pre-commit run --all-files
cargo update
Maybe you will be interested in:
path-absolutize when it will out of beta.