{"id":28273414,"url":"https://github.com/uggla/state_type_pattern","last_synced_at":"2025-06-23T00:39:12.959Z","repository":{"id":291968594,"uuid":"979377568","full_name":"uggla/state_type_pattern","owner":"uggla","description":"A simple example of state type pattern in rust","archived":false,"fork":false,"pushed_at":"2025-05-07T12:30:40.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-11T06:50:23.021Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/uggla.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,"zenodo":null}},"created_at":"2025-05-07T12:23:12.000Z","updated_at":"2025-05-07T12:30:44.000Z","dependencies_parsed_at":"2025-05-07T13:35:08.781Z","dependency_job_id":"3e0ced33-dced-4db4-b942-5974ba742414","html_url":"https://github.com/uggla/state_type_pattern","commit_stats":null,"previous_names":["uggla/state_type_pattern"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/uggla/state_type_pattern","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uggla%2Fstate_type_pattern","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uggla%2Fstate_type_pattern/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uggla%2Fstate_type_pattern/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uggla%2Fstate_type_pattern/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uggla","download_url":"https://codeload.github.com/uggla/state_type_pattern/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uggla%2Fstate_type_pattern/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260039622,"owners_count":22949651,"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":[],"created_at":"2025-05-21T00:18:12.945Z","updated_at":"2025-06-15T19:31:43.968Z","avatar_url":"https://github.com/uggla.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🦀 Type-State Pattern in Rust\n\nThis repository demonstrates the use of the **type-state pattern** in Rust\n— a design pattern where an object’s state is encoded in its type. This\nallows the compiler to enforce valid state transitions at compile time,\nreducing bugs and improving correctness.\n\n## 🎯 Main Goal\n\nThe project shows how to model different object states using distinct types\nand make state transitions explicit through methods. For example, a method\nlike `send()` can only be called if the object is in a `Connected` state,\nand attempting to call it while `Disconnected` simply won’t compile.\n\n## 📚 Additional Learning Points\n\n- ✅ **How to import and organize modules**  \n  The code is structured across multiple files and modules. It’s a practical\n  example of idiomatic module management and importing in Rust, with clear\n  separation of concerns.\n\n- ✅ **How to write functional tests**  \n  Beyond unit tests, the repository includes **functional tests** under the\n  `tests/` directory. These test higher-level behaviors and validate that\n  state transitions work as intended across components.\n\n## ✅ Why Use This Project\n\nThis repository is a useful reference for Rust developers who want to:\n\n- Understand and apply the type-state pattern\n- Learn proper project structure with multiple modules\n- Write functional and integration-style tests\n- Leverage Rust’s type system to enforce business rules at compile time\n\n---\n\n\u003e This is a minimal but complete example of safe state management in Rust\n\u003e using types. Feel free to use it as a starting point for your own stateful\n\u003e abstractions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuggla%2Fstate_type_pattern","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuggla%2Fstate_type_pattern","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuggla%2Fstate_type_pattern/lists"}