{"id":20989909,"url":"https://github.com/iddm/fxsm","last_synced_at":"2025-07-16T17:33:02.056Z","repository":{"id":57632837,"uuid":"83443612","full_name":"iddm/fxsm","owner":"iddm","description":"A FSM procedural macro for enums","archived":false,"fork":false,"pushed_at":"2023-12-05T18:55:59.000Z","size":14,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-13T11:46:05.843Z","etag":null,"topics":["finite-state-machine","fsm","rust","rust-library","state-machine"],"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/iddm.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":"2017-02-28T14:44:48.000Z","updated_at":"2023-12-05T18:56:03.000Z","dependencies_parsed_at":"2024-11-19T06:41:32.250Z","dependency_job_id":null,"html_url":"https://github.com/iddm/fxsm","commit_stats":null,"previous_names":["iddm/fxsm","vityafx/fxsm"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/iddm/fxsm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iddm%2Ffxsm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iddm%2Ffxsm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iddm%2Ffxsm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iddm%2Ffxsm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iddm","download_url":"https://codeload.github.com/iddm/fxsm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iddm%2Ffxsm/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265527559,"owners_count":23782480,"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":["finite-state-machine","fsm","rust","rust-library","state-machine"],"created_at":"2024-11-19T06:26:41.492Z","updated_at":"2025-07-16T17:33:01.990Z","avatar_url":"https://github.com/iddm.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fxsm\n\n[![](https://meritbadge.herokuapp.com/fxsm)](https://crates.io/crates/fxsm) [![](https://travis-ci.org/iddm/fxsm.svg?branch=master)](https://travis-ci.org/iddm/urlshortener-rs)\n[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)\n\n\nA very simple state machine procedural macro for enums.\n\n## How does it work\n\nIt simply generates match conditions on your enums in appropriate `StateMachine` trait's methods.\n You may use the state machine through a [`StateMachine`](https://github.com/iddm/fxsm/blob/master/fxsm/src/lib.rs) trait.\n  \n\n## Usage\n\n1. Add `fxsm` as dependency in your `Cargo.toml`:\n\n ```toml\n [dependencies]\n fxsm-derive = \"0.2\"\n fxsm = \"0.2\"\n ```\n\n2. Create a State Machine:\n\n ```rust\n #[macro_use]\n extern crate fxsm_derive;\n extern crate fxsm;\n \n \n #[derive(Clone, Debug, FiniteStateMachine)]\n enum CupState {\n     #[state_transitions(Checkins, Aborted, Rescheduled)]\n     Waiting,\n     #[state_transitions(InProgress, Aborted, Rescheduled)]\n     Checkins,\n     #[state_transitions(Finished, Aborted, Rescheduled)]\n     InProgress(String),\n \n     // Finish-states\n     Aborted(u64),\n     Rescheduled { info: String },\n     Finished,\n }\n ```\n\n3. Use it:\n\n ```rust\n fn main() {\n     use fxsm::{ StateMachine };\n     let mut fsm = CupState::Waiting;\n     assert_eq!(CupState::finish_states(), 3);\n     // must not be able to change to itself\n     assert!(!fsm.can_change(CupState::Waiting));\n     assert!(fsm.can_change(CupState::Checkins));\n     assert!(!fsm.can_change(CupState::InProgress(String::default())));\n     assert!(fsm.can_change(CupState::Aborted(0u64)));\n     assert!(fsm.can_change(CupState::Rescheduled{info: String::default()}));\n     assert!(!fsm.can_change(CupState::Finished));\n     assert!(!fsm.at_finish_state());\n \n     assert!(fsm.change(CupState::Checkins));\n     assert!(!fsm.can_change(CupState::Waiting));\n     assert!(fsm.can_change(CupState::Aborted(0u64)));\n     assert!(fsm.can_change(CupState::Rescheduled{info: String::default()}));\n     assert!(fsm.can_change(CupState::InProgress(String::default())));\n     assert!(!fsm.can_change(CupState::Finished));\n     assert!(!fsm.at_finish_state());\n \n     // You still always able to change it without FSM rules:\n     fsm = CupState::Finished;\n     assert!(fsm.at_finish_state());\n     assert!(CupState::is_finish_state(CupState::Finished));\n     assert!(CupState::is_finish_state(CupState::Aborted(0u64)));\n     assert!(CupState::is_finish_state(CupState::Rescheduled{ info: String::default()}));\n     assert!(!CupState::is_finish_state(CupState::Waiting));\n     assert!(!CupState::is_finish_state(CupState::Checkins));\n     assert!(!CupState::is_finish_state(CupState::InProgress(String::default())));\n }\n ```\n \n More and updated examples are in [examples directory](https://github.com/iddm/fxsm/blob/master/examples).\n\n## License\n\nThis project is [licensed under the MIT license](https://github.com/iddm/urlshortener-rs/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiddm%2Ffxsm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiddm%2Ffxsm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiddm%2Ffxsm/lists"}