{"id":13503087,"url":"https://github.com/softprops/recap","last_synced_at":"2025-04-05T00:08:31.908Z","repository":{"id":45251925,"uuid":"181353974","full_name":"softprops/recap","owner":"softprops","description":"deserialize typed structures from regex captures","archived":false,"fork":false,"pushed_at":"2023-12-28T01:18:27.000Z","size":2451,"stargazers_count":170,"open_issues_count":6,"forks_count":12,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-17T12:00:00.741Z","etag":null,"topics":["regex","serde"],"latest_commit_sha":null,"homepage":null,"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/softprops.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}},"created_at":"2019-04-14T18:47:18.000Z","updated_at":"2025-02-07T10:26:58.000Z","dependencies_parsed_at":"2024-01-18T23:27:00.595Z","dependency_job_id":"3cf9d305-f217-4532-8c66-3fb53302b1f6","html_url":"https://github.com/softprops/recap","commit_stats":{"total_commits":44,"total_committers":4,"mean_commits":11.0,"dds":"0.11363636363636365","last_synced_commit":"21208d97a9a1c76e26e6bb2a9838b28482dce527"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softprops%2Frecap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softprops%2Frecap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softprops%2Frecap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softprops%2Frecap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/softprops","download_url":"https://codeload.github.com/softprops/recap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247266564,"owners_count":20910836,"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":["regex","serde"],"created_at":"2024-07-31T22:02:36.466Z","updated_at":"2025-04-05T00:08:31.883Z","avatar_url":"https://github.com/softprops.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# recap [![Main](https://github.com/softprops/recap/actions/workflows/main.yml/badge.svg)](https://github.com/softprops/recap/actions/workflows/main.yml) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE) [![crates.io](https://img.shields.io/crates/v/recap.svg)](https://crates.io/crates/recap) [![Released API docs](https://docs.rs/recap/badge.svg)](http://docs.rs/recap) [![Master API docs](https://img.shields.io/badge/docs-master-green.svg)](https://softprops.github.io/recap)\n\n\u003e deserialize named capture groups into typesafe structs\n\nRecap is provides what [envy](https://crates.io/crates/envy) provides for environment variables, for[ named capture groups](https://www.regular-expressions.info/named.html). Named regex capture groups are like any other regex capture group but have the extra property that they are associated with name. i.e `(?P\u003cname-of-capture-group\u003esome-pattern)`\n\n## 🤔 who is this for\n\nYou may find this crate useful for cases where your application needs to extract information from string input provided by a third party that has a loosely structured format.\n\nA common usecase for this is when you are dealing with log file data that was not stored in a particular structured format like JSON, but rather in a format that can be represented with a pattern.\n\nYou may also find this useful parsing other loosely formatted data patterns.\n\nThis crate would be less appropriate for cases where your input is provided in a more structured format, like JSON.\nI recommend using a crate like [`serde-json`](https://crates.io/crates/serde_json) for those cases instead.\n\n## 📦 install\n\nAdd the following to your `Cargo.toml` file.\n\n```toml\n[dependencies]\nrecap = \"0.1\"\n```\n\n## 🤸 usage\n\nA typical recap usage looks like the following. Assuming your Rust program looks something like this...\n\n\u003e 💡 These examples use Serde's [derive feature](https://serde.rs/derive.html)\n\n```rust\nuse recap::Recap;\nuse serde::Deserialize;\nuse std::error::Error;\n\n#[derive(Debug, Deserialize, Recap)]\n#[recap(regex = r#\"(?x)\n    (?P\u003cfoo\u003e\\d+)\n    \\s+\n    (?P\u003cbar\u003etrue|false)\n    \\s+\n    (?P\u003cbaz\u003e\\S+)\n  \"#)]\nstruct LogEntry {\n    foo: usize,\n    bar: bool,\n    baz: String,\n}\n\nfn main() -\u003e Result\u003c(), Box\u003cdyn Error\u003e\u003e {\n    let logs = r#\"1 true hello\n  2 false world\"#;\n\n    for line in logs.lines() {\n        let entry: LogEntry = line.parse()?;\n        println!(\"{:#?}\", entry);\n    }\n\n    Ok(())\n}\n\n```\n\n\u003e 👭 Consider this crate a cousin of [envy](https://github.com/softprops/envy), a crate for deserializing environment variables into typesafe structs.\n\nDoug Tangren (softprops) 2019\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftprops%2Frecap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoftprops%2Frecap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftprops%2Frecap/lists"}