path_as_uri 0.1.0

Convert a path to a URI
Documentation
  • Coverage
  • 50%
    3 out of 6 items documented1 out of 3 items with examples
  • Size
  • Source code size: 23.37 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 3.72 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 36s Average build duration of successful builds.
  • all releases: 36s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Alirex/rs_lib_i_path_as_uri
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Alirex

Path as URI

Allows you to get the path of a file as a URI. That can be clicked in the terminal.

Example

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);
}

🤔 Why?

Why do I need this?

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:

Why do I need this library?

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.

Why just don't concatenate the string?

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.

🛠️ Dev

Register pre-commit hooks

pre-commit install

Run pre-commit hooks

pre-commit run --all-files

Update dependencies

cargo update

Other

Maybe you will be interested in: