{"id":18938307,"url":"https://github.com/faiface/par","last_synced_at":"2025-05-16T15:05:21.017Z","repository":{"id":249224678,"uuid":"830824355","full_name":"faiface/par","owner":"faiface","description":"⅋ — session types for Rust","archived":false,"fork":false,"pushed_at":"2024-11-19T00:26:46.000Z","size":94,"stargazers_count":186,"open_issues_count":3,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-05-14T23:33:11.307Z","etag":null,"topics":[],"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/faiface.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"faiface"}},"created_at":"2024-07-19T04:43:57.000Z","updated_at":"2025-05-12T12:49:55.000Z","dependencies_parsed_at":"2024-08-29T17:20:35.828Z","dependency_job_id":"55e80220-ccb0-4dfb-ada9-92e359428582","html_url":"https://github.com/faiface/par","commit_stats":null,"previous_names":["faiface/par"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faiface%2Fpar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faiface%2Fpar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faiface%2Fpar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faiface%2Fpar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/faiface","download_url":"https://codeload.github.com/faiface/par/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254553959,"owners_count":22090417,"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":"2024-11-08T12:14:02.887Z","updated_at":"2025-05-16T15:05:20.998Z","avatar_url":"https://github.com/faiface.png","language":"Rust","funding_links":["https://github.com/sponsors/faiface"],"categories":["Rust"],"sub_categories":[],"readme":"# ⅋ — session types for Rust\n\n[![Crates.io][crates-badge]][crates-url]\n[![Docs.rs][docs-badge]][docs-url]\n[![MIT licensed][mit-badge]][mit-url]\n\n[crates-badge]: https://img.shields.io/crates/v/par\n[crates-url]: https://crates.io/crates/par\n[docs-badge]: https://img.shields.io/docsrs/par\n[docs-url]: https://docs.rs/par/latest/par\n[mit-badge]: https://img.shields.io/badge/license-MIT-blue.svg\n[mit-url]: https://github.com/faiface/par/blob/main/LICENSE\n\n[cheatsheet-url]: https://github.com/faiface/par/blob/main/CHEATSHEET.md\n[chat-example-url]: https://github.com/faiface/par/blob/main/examples/chat.rs\n\n### [Cheatsheet][cheatsheet-url]\n\n### [Showcase example: Chat server][chat-example-url]\n\n\u003cdetails\u003e\n\u003csummary\u003eTry it out!\u003c/summary\u003e\n\nThis example is a simple single-room chat server that operates via WebSocket. After\ncloning the repository, run it with:\n\n```plain\n\u003e cargo run --example chat\nListening on: 127.0.0.1:3000\n```\n\nUse any WebSocket client to connect to it. For example, I like to use [Postman](https://www.postman.com).\n\nRight after connecting, you should get a message:\n\n```plain\n\u003e What's your name?\n```\n\nRespond with your nickname and you're in the room. Make multiple connections and chat away!\n\n| Alice | Bob |\n| --- | --- |\n| `\u003e What's your name?` |  |\n| **`alice`** |  |\n| `\u003e alice joined` |  |\n|  | `\u003e What's your name?` |\n|  | **`bob`** |\n| `\u003e bob joined` | `\u003e bob joined` |\n| **`hey bob!`** |  |\n| `alice\u003e hey bob!` | `alice\u003e hey bob!` |\n|  | **`hey alice! how are you doing?`** |\n| `bob\u003e hey alice! how are you doing?` | `bob\u003e hey alice! how are you doing?` |\n| **`good! session types are cool ;)`** |  |\n| `alice\u003e good! session types are cool ;)` | `alice\u003e good! session types are cool ;)` |\n\u003c/details\u003e\n\n## Features\n\n- **Specify full concurrent protocols** — Sequencing, branching, recursion, higher-order patterns.\n- **Type-checked protocol adherence** — Expectations delivered, obligations fulfilled.\n- **Deadlock freedom** — Cyclic communication is statically ruled out.\n- **Multiple concurrent participants.**\n- **Fits well with Rust's type system:**\n  - Use `enum`s for making choices.\n  - Use recursion on types for cyclic protocols.\n- **Built on top of `async`/`.await`. Runtime agnostic.**\n- **Ergonomic design** — eg. `atm.choose(Operation::CheckBalance)`\n- **Standard patterns in modules:**\n  - [**Queue**](https://docs.rs/par/latest/par/queue/index.html) — Transmit an arbitrary number of items in order.\n  - [**Server**](https://docs.rs/par/latest/par/server/index.html) — Handle a dynamic number of clients concurrently.\n- **No unsafe!**\n- **Accessible [documentation][docs-url] as a learning tool.**\n\n## Introduction\n\n**What's a session type, anyway?** It's a description an entire external behavior\nof a concurrent, message-passing process. From the first message, through every\npossible path and interaction that can be made with it, to all the ways it can\nfinish.\n\nWhen implementing a concurrent program according to a session type, the type tells\nwhat can happen at any point in the program. When we have to send a message, when to\nselect a path to continue, when to wait for someone else to make a choice and adapt.\n\nCrucially, the types are designed to provide some useful guarantees:\n\n- **Protocol adherence** — Expectations delivered, obligations fulfilled.\n- **Deadlock freedom** — Cyclic communication is statically ruled out.\n\n_Protocol adherence_ means that when interacting with a process described by a session\ntype, we can be sure (unless it crashes) that it will behave according to the protocol\nspecified by its type. There will no unexpected messages, nor forgotten obligations.\nJust like we can rely on a function to return a string if it says so, we can rely on\na process to send a string if its specified anywhere within its session type.\n\n_Deadlock freedom_ means that deadlocks can't happen, without dirty tricks anyway. It is\nachieved by imposing a certain structure on how processes are connected. It can take\na bit of getting used to, but it becomes very important when implementing very complex\nconcurrent systems.\n\n\u003e ❓ Reading this, one may easily think, _\"I don't see deadlocks happen in practice...\"_,\nand that's a valid objection! But it arises from our concurrent systems not being very\ncomplex due to a lack of tools and types to design and implement them reliably.\nAt high levels of complexity, deadlocks become an issue, and having them ruled out\nproves crucial.\n\nUsing session types, complex concurrent systems can be modelled and implemented with confidence,\nas any type-checked program is guaranteed to adhere to its protocol, and avoid any deadlocks.\nMessage passing itself ensures natural synchronization.\n\nLastly, session types give names to concurrent concepts and patterns, which\nenables high levels of abstraction and composability. That makes it easier to\nreason and talk about large concurrent systems.\n\n\u003e 📚 The particular flavor of session types presented here is a full implementation\nof propositional linear logic. However, no knowledge of linear logic is required to use\nor understand this library.\n\n[**Continue reading the tutorial...**][docs-url]\n\n---\n\n❤️ If you like what you see, and want to see more, [**consider sponsoring!**](https://github.com/sponsors/faiface)\nIt really helps with being able\nto do what I love, alongside navigating life.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffaiface%2Fpar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffaiface%2Fpar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffaiface%2Fpar/lists"}