{"id":15689901,"url":"https://github.com/nozaq/csa-rs","last_synced_at":"2025-05-07T23:36:01.818Z","repository":{"id":21824750,"uuid":"94145627","full_name":"nozaq/csa-rs","owner":"nozaq","description":"A Shogi game serialization/deserialization library in CSA format.","archived":false,"fork":false,"pushed_at":"2025-02-03T18:22:31.000Z","size":52,"stargazers_count":9,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-13T15:17:45.523Z","etag":null,"topics":["board-game","csa","parsing","rust","rust-crate","shogi"],"latest_commit_sha":null,"homepage":"https://docs.rs/csa","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/nozaq.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":"2017-06-12T22:19:32.000Z","updated_at":"2024-05-31T16:47:11.000Z","dependencies_parsed_at":"2024-10-09T13:45:12.272Z","dependency_job_id":null,"html_url":"https://github.com/nozaq/csa-rs","commit_stats":{"total_commits":35,"total_committers":5,"mean_commits":7.0,"dds":0.5142857142857142,"last_synced_commit":"714d347474b8ff32952066e6a20ea70551b7d0ef"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nozaq%2Fcsa-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nozaq%2Fcsa-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nozaq%2Fcsa-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nozaq%2Fcsa-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nozaq","download_url":"https://codeload.github.com/nozaq/csa-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249850093,"owners_count":21334423,"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":["board-game","csa","parsing","rust","rust-crate","shogi"],"created_at":"2024-10-03T18:05:00.163Z","updated_at":"2025-04-20T04:33:10.022Z","avatar_url":"https://github.com/nozaq.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# csa-rs\n\n[![Github Actions](https://github.com/nozaq/csa-rs/workflows/build/badge.svg)](https://github.com/nozaq/csa-rs/actions?workflow=build)\n[![Coverage Status](https://coveralls.io/repos/github/nozaq/csa-rs/badge.svg)](https://coveralls.io/github/nozaq/csa-rs)\n[![crates.io](https://img.shields.io/crates/v/csa.svg)](https://crates.io/crates/csa)\n[![docs.rs](https://docs.rs/csa/badge.svg)](https://docs.rs/csa)\n\nA Shogi game serialization/deserialization library in CSA format.\nCSA format is a plaintext format for recording Shogi games. This library supports parsing CSA-formatted string as well as composing CSA-formatted string from structs. Detail about CSA format is found at [here](http://www.computer-shogi.org/protocol/record_v22.html).\n\n[Documentation](https://docs.rs/csa)\n\n## Usage\n\nBelow is an example of parsing CSA-formatted string into structs.\n\n```rust\nuse std::time::Duration;\nuse csa::{parse_csa, Action, Color, GameRecord, MoveRecord, PieceType, Square};\n\nlet csa_str = \"\\\nV2.2\nN+NAKAHARA\nN-YONENAGA\n$EVENT:13th World Computer Shogi Championship\nPI\n+\n+2726FU\nT12\n\";\n\nlet game = parse_csa(csa_str).expect(\"failed to parse the csa content\");\nassert_eq!(game.black_player, Some(\"NAKAHARA\".to_string()));\nassert_eq!(game.white_player, Some(\"YONENAGA\".to_string()));\nassert_eq!(game.event, Some(\"13th World Computer Shogi Championship\".to_string()));\nassert_eq!(game.moves[0],  MoveRecord{\n    action: Action::Move(Color::Black, Square::new(2, 7), Square::new(2, 6), PieceType::Pawn),\n    time: Some(Duration::from_secs(12))\n});\n```\n\nIn contrast, structs can be composed into CSA-formatted string.\n\n```rust\nuse std::time::Duration;\nuse csa::{ Action, Color, GameRecord, MoveRecord, PieceType, Square};\n\nlet mut g = GameRecord::default();\ng.black_player = Some(\"NAKAHARA\".to_string());\ng.white_player = Some(\"YONENAGA\".to_string());\ng.event = Some(\"13th World Computer Shogi Championship\".to_string());\ng.moves.push(MoveRecord {\n    action: Action::Move(\n        Color::Black,\n        Square::new(2, 7),\n        Square::new(2, 6),\n        PieceType::Pawn,\n    ),\n    time: Some(Duration::from_secs(5)),\n});\ng.moves.push(MoveRecord {\n    action: Action::Toryo,\n    time: None,\n});\n\nlet csa_str = \"\\\nV2.2\nN+NAKAHARA\nN-YONENAGA\n$EVENT:13th World Computer Shogi Championship\nPI\n+\n+2726FU\nT5\n%TORYO\n\";\n\nassert_eq!(csa_str, g.to_string());\n```\n\n## License\n\n`csa-rs` is licensed under the MIT license. Please read the [LICENSE](LICENSE) file in this repository for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnozaq%2Fcsa-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnozaq%2Fcsa-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnozaq%2Fcsa-rs/lists"}