{"id":18084840,"url":"https://github.com/jwodder/in-place-rs","last_synced_at":"2025-04-12T20:09:43.785Z","repository":{"id":166233404,"uuid":"641706462","full_name":"jwodder/in-place-rs","owner":"jwodder","description":"In-place file processing","archived":false,"fork":false,"pushed_at":"2025-02-10T21:07:57.000Z","size":84,"stargazers_count":4,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T20:09:36.147Z","etag":null,"topics":["available-on-crates-io","edit","in-place","rust","tempfile"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jwodder.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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":"2023-05-17T02:13:34.000Z","updated_at":"2025-02-10T21:08:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"dcbb484c-f566-4cc1-8350-a8001ab5cb1f","html_url":"https://github.com/jwodder/in-place-rs","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwodder%2Fin-place-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwodder%2Fin-place-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwodder%2Fin-place-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwodder%2Fin-place-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jwodder","download_url":"https://codeload.github.com/jwodder/in-place-rs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248625493,"owners_count":21135513,"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":["available-on-crates-io","edit","in-place","rust","tempfile"],"created_at":"2024-10-31T15:08:24.556Z","updated_at":"2025-04-12T20:09:43.750Z","avatar_url":"https://github.com/jwodder.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)\n[![CI Status](https://github.com/jwodder/in-place-rs/actions/workflows/test.yml/badge.svg)](https://github.com/jwodder/in-place-rs/actions/workflows/test.yml)\n[![codecov.io](https://codecov.io/gh/jwodder/in-place-rs/branch/master/graph/badge.svg)](https://codecov.io/gh/jwodder/in-place-rs)\n[![Minimum Supported Rust Version](https://img.shields.io/badge/MSRV-1.74-orange)](https://www.rust-lang.org)\n[![MIT License](https://img.shields.io/github/license/jwodder/in-place-rs.svg)](https://opensource.org/licenses/MIT)\n\n[GitHub](https://github.com/jwodder/in-place-rs) | [crates.io](https://crates.io/crates/in-place) | [Documentation](https://docs.rs/in-place) | [Issues](https://github.com/jwodder/in-place-rs/issues) | [Changelog](https://github.com/jwodder/in-place-rs/blob/master/CHANGELOG.md)\n\nThe `in_place` library provides an `InPlace` type for reading \u0026 writing a file\n\"in-place\": data that you write ends up at the same filepath that you read\nfrom, and `in_place` takes care of all the necessary mucking about with\ntemporary files for you.\n\nFor example, given the file `somefile.txt`:\n\n```text\n'Twas brillig, and the slithy toves\n    Did gyre and gimble in the wabe;\nAll mimsy were the borogoves,\n    And the mome raths outgrabe.\n```\n\nand the following program:\n\n```rust\nuse in_place::InPlace;\nuse std::io::{BufRead, BufReader, Write};\n\nfn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    let inp = InPlace::new(\"somefile.txt\").open()?;\n    let reader = BufReader::new(inp.reader());\n    let mut writer = inp.writer();\n    for line in reader.lines() {\n        let mut line = line?;\n        line.retain(|ch| !\"AEIOUaeiou\".contains(ch));\n        writeln!(writer, \"{line}\")?;\n    }\n    inp.save()?;\n    Ok(())\n}\n```\n\nafter running the program, `somefile.txt` will have been edited in place,\nreducing it to just:\n\n```text\n'Tws brllg, nd th slthy tvs\n    Dd gyr nd gmbl n th wb;\nll mmsy wr th brgvs,\n    nd th mm rths tgrb.\n```\n\nand no sign of those pesky vowels remains!  If you want a sign of those pesky\nvowels to remain, you can instead save the file's original contents in, say,\n`somefile.txt~` by opening the file with:\n\n```rust\nlet inp = InPlace::new(\"somefile.txt\")\n    .backup(in_place::Backup::Append(\"~\".into()))\n    .open()?;\n```\n\nor save to `someotherfile.txt` with:\n\n```rust\nlet inp = InPlace::new(\"somefile.txt\")\n    .backup(in_place::Backup::Path(\"someotherfile.txt\".into()))\n    .open()?;\n```\n\nIf you decide halfway through that you don't want to edit the file (say,\nbecause an unrecoverable error occurs), calling `inp.discard()` instead of\n`inp.save()` will close the file handles and reset things to the way they were\nbefore.  Any changes are also discarded if `inp` is dropped without saving,\nexcept that in that case any errors are silently ignored.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwodder%2Fin-place-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjwodder%2Fin-place-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwodder%2Fin-place-rs/lists"}