{"id":22293438,"url":"https://github.com/rrrodzilla/pathtrim","last_synced_at":"2025-03-25T22:17:51.378Z","repository":{"id":57653565,"uuid":"436485232","full_name":"rrrodzilla/pathtrim","owner":"rrrodzilla","description":"trimpath - When all you need is the last few parts of a path in Rust, this crate implements the TrimmablePath trait on std::path::Path so you can easily obtain the last *n* parts of the path.","archived":false,"fork":false,"pushed_at":"2023-06-24T04:28:57.000Z","size":22,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-24T17:41:43.019Z","etag":null,"topics":["directory-path","directory-trimmer","file-path-utils","file-system","fs-path","fs-utils","path","path-extractor","path-handling","path-helper","path-manipulation","path-parser","path-processing","path-shortener","path-trimming","path-utils","rust","rust-crate","rust-library","trimmable-path"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rrrodzilla.png","metadata":{"files":{"readme":"readme.md","changelog":"changelog.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-09T04:45:23.000Z","updated_at":"2024-01-05T19:43:29.000Z","dependencies_parsed_at":"2024-12-03T17:29:31.918Z","dependency_job_id":"6bb1fe9a-4be1-4328-8716-e8624cac0444","html_url":"https://github.com/rrrodzilla/pathtrim","commit_stats":{"total_commits":8,"total_committers":1,"mean_commits":8.0,"dds":0.0,"last_synced_commit":"1de2349034c6b20b8d3b9b201e2e35e02ec5248b"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rrrodzilla%2Fpathtrim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rrrodzilla%2Fpathtrim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rrrodzilla%2Fpathtrim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rrrodzilla%2Fpathtrim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rrrodzilla","download_url":"https://codeload.github.com/rrrodzilla/pathtrim/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245550681,"owners_count":20633883,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["directory-path","directory-trimmer","file-path-utils","file-system","fs-path","fs-utils","path","path-extractor","path-handling","path-helper","path-manipulation","path-parser","path-processing","path-shortener","path-trimming","path-utils","rust","rust-crate","rust-library","trimmable-path"],"created_at":"2024-12-03T17:29:08.011Z","updated_at":"2025-03-25T22:17:51.356Z","avatar_url":"https://github.com/rrrodzilla.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pathtrim\n\n`pathtrim` is a simple, yet powerful Rust library that helps you obtain the last *n* parts of a filesystem path. It provides a seamless way to work with paths in a cross-platform manner, making it a great choice for projects that need to run on different systems like Unix, macOS, and Windows.\n\nWith `pathtrim`, you get a clean and intuitive API for handling path trimming, out-of-the-box support for different platforms, and the confidence that comes with strong safety guarantees, thanks to the use of Rust's features and ecosystem.\n\n[![Crates.io](https://img.shields.io/crates/v/pathtrim)](https://crates.io/crates/pathtrim)\n[![Crates.io (Downloads)](https://img.shields.io/crates/d/pathtrim)](https://crates.io/crates/pathtrim)\n[![Continuous integration](https://github.com/rrrodzilla/pathtrim/actions/workflows/Continuous%20Integration.yml/badge.svg)](https://github.com/rrrodzilla/pathtrim/actions/workflows/Continuous%20Integration.yml)\n[![Docs.rs](https://docs.rs/pathtrim/badge.svg)](https://docs.rs/pathtrim)\n\n## 💡 Features\n\n- Obtain the last *n* components of a path with just a line of code.\n- Cross-platform: works seamlessly on Unix, macOS, and Windows.\n- Built upon the powerful [std::path](https://doc.rust-lang.org/stable/std/path/index.html) module.\n- Highly configurable, with a simple and easy-to-understand API.\n\n## 🚀 Getting Started\n\nAdd this to your `Cargo.toml`:\n\n```toml\n[dependencies]\npathtrim = \"0.2.0\"\n```\n\nAnd then import the trait in the file where you want to use it:\n\n```rust\nuse std::path::Path;\nuse pathtrim::TrimmablePath;\n```\n\n### Examples\n\n#### Basic Usage\n\n```rust\nuse std::path::Path;\nuse pathtrim::TrimmablePath;\n\nlet path = Path::new(\"/usr/local/bin/application\");\nlet trimmed = path.trim_to_nth(2).unwrap();\nassert_eq!(trimmed.to_str().unwrap(), \"bin/application\");\n```\n\n#### Different Platforms\n\nUnix:\n\n```rust\nuse std::path::Path;\nuse pathtrim::TrimmablePath;\nlet path = Path::new(\"/usr/local/bin/application\");\nlet trimmed = path.trim_to_nth(3).unwrap();\nassert_eq!(trimmed.to_str().unwrap(), \"local/bin/application\");\n```\n\nWindows:\n\n```rust\nuse std::path::Path;\nuse pathtrim::TrimmablePath;\nlet path = Path::new(r\"C:\\Program Files\\package\\bin\\application\");\nlet trimmed = path.trim_to_nth(2).unwrap();\nassert_eq!(trimmed.to_str().unwrap(), r\"bin\\application\");\n```\n\n#### Edge Cases\n\n```rust\nuse std::path::Path;\nuse pathtrim::TrimmablePath;\nlet path = Path::new(\"/\");\nlet trimmed = path.trim_to_nth(1);\nassert!(trimmed.is_none());\n```\n\n## 📚 Further Reading\n\nTo gain a deeper understanding of path components and various related APIs, refer to the official Rust documentation:\n\n- [std::path](https://doc.rust-lang.org/stable/std/path/index.html)\n- [std::path::Components](https://doc.rust-lang.org/stable/std/path/struct.Components.html)\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frrrodzilla%2Fpathtrim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frrrodzilla%2Fpathtrim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frrrodzilla%2Fpathtrim/lists"}