{"id":17078835,"url":"https://github.com/hatoo/stap","last_synced_at":"2025-07-22T12:33:57.357Z","repository":{"id":240356984,"uuid":"802408447","full_name":"hatoo/stap","owner":"hatoo","description":"Stateful parser","archived":false,"fork":false,"pushed_at":"2024-06-03T05:41:20.000Z","size":67,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-05T07:44:17.723Z","etag":null,"topics":["async","parse","parser","rust"],"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/hatoo.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2024-05-18T07:59:05.000Z","updated_at":"2024-06-03T05:41:23.000Z","dependencies_parsed_at":"2024-05-18T09:25:44.281Z","dependency_job_id":"b9e935a3-7978-4436-9789-25c33d8ed3fd","html_url":"https://github.com/hatoo/stap","commit_stats":null,"previous_names":["hatoo/corp"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hatoo/stap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hatoo%2Fstap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hatoo%2Fstap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hatoo%2Fstap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hatoo%2Fstap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hatoo","download_url":"https://codeload.github.com/hatoo/stap/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hatoo%2Fstap/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266496399,"owners_count":23938711,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["async","parse","parser","rust"],"created_at":"2024-10-14T12:23:41.486Z","updated_at":"2025-07-22T12:33:57.290Z","avatar_url":"https://github.com/hatoo.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# stap\n\n[![Crates.io](https://img.shields.io/crates/v/stap.svg)](https://crates.io/crates/stap)\n\n`stap` (**sta**teful **p**arser) is a library of stateful parser for streaming input using `async` syntax.\n\nWhen a input isn't enough for parsing, `stap` remembers the curent state and waits to more inputs and parses them when the input is supplied.\n\n```rust\nuse futures::FutureExt;\nuse stap::{many1, Anchor, Cursor, Input, Parsing};\n\nfn main() {\n    let mut input = Input::new(Cursor {\n        buf: Vec::\u003cu8\u003e::new(),\n        index: 0,\n    });\n\n    let mut parsing = Parsing::new(\u0026mut input, |mut iref| {\n        async move {\n            // anchoring the current index\n            // restoring the index if parsing fails (= when dropped)\n            let mut anchor = Anchor::new(\u0026mut iref);\n\n            let num = many1(\u0026mut anchor, |b| b.is_ascii_digit()).await?;\n            // Since the parser holds state, this output is showed up only once.\n            dbg!(\u0026num);\n            let alpha = many1(\u0026mut anchor, |b| b.is_ascii_alphabetic()).await?;\n            dbg!(\u0026alpha);\n\n            // parsing is successful, so we can forget the anchor in other words, current index of the input is valid.\n            anchor.forget();\n\n            Ok::\u003c_, ()\u003e((num, alpha))\n        }\n        // This makes the future `Unpin`, currently this is required but any workaround is welcome.\n        .boxed_local()\n    });\n\n    // There is no input to parse, so parsing should fail.\n    assert!(!parsing.poll());\n\n    parsing.cursor_mut().buf.extend_from_slice(b\"123a\");\n    // The parser recognizing the input as a number followed by an alphabet. But because of there may be more alphabets, it should fail.\n    assert!(!parsing.poll());\n\n    parsing.cursor_mut().buf.extend_from_slice(b\"bc;\");\n    // the parser should ends.\n    assert!(parsing.poll());\n\n    dbg!(parsing.into_result());\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhatoo%2Fstap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhatoo%2Fstap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhatoo%2Fstap/lists"}