{"id":16151268,"url":"https://github.com/njasm/blunt","last_synced_at":"2025-04-06T22:44:53.158Z","repository":{"id":46645024,"uuid":"361464442","full_name":"njasm/blunt","owner":"njasm","description":"Highly opinionated way to build asynchronous Websocket servers with Rust","archived":false,"fork":false,"pushed_at":"2021-10-01T23:32:50.000Z","size":182,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-13T05:15:51.711Z","etag":null,"topics":["asynchronous","network-programming","opinionated","rust","rust-lang","tokio","websocket","websockets"],"latest_commit_sha":null,"homepage":"","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/njasm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE-2.0","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-04-25T15:23:23.000Z","updated_at":"2021-10-01T23:32:53.000Z","dependencies_parsed_at":"2022-08-29T23:41:36.987Z","dependency_job_id":null,"html_url":"https://github.com/njasm/blunt","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/njasm%2Fblunt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/njasm%2Fblunt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/njasm%2Fblunt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/njasm%2Fblunt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/njasm","download_url":"https://codeload.github.com/njasm/blunt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247563915,"owners_count":20958971,"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":["asynchronous","network-programming","opinionated","rust","rust-lang","tokio","websocket","websockets"],"created_at":"2024-10-10T00:55:30.391Z","updated_at":"2025-04-06T22:44:53.141Z","avatar_url":"https://github.com/njasm.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"Blunt\n=\n\n[\u003cimg alt=\"github\" src=\"https://img.shields.io/badge/github-njasm/blunt-blueviolet?style=for-the-badge\u0026labelColor=555555\u0026logo=github\" height=\"20\"\u003e](https://github.com/njasm/blunt)\n[\u003cimg alt=\"crates.io\" src=\"https://img.shields.io/crates/v/blunt.svg?style=for-the-badge\u0026color=fc8d62\u0026logo=rust\" height=\"20\"\u003e](https://crates.io/crates/blunt)\n[\u003cimg alt=\"docs.rs\" src=\"https://img.shields.io/badge/docs.rs-blunt-66c2a5?style=for-the-badge\u0026labelColor=555555\u0026logoColor=white\u0026logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K\" height=\"20\"\u003e](https://docs.rs/blunt)\n[\u003cimg alt=\"build status\" src=\"https://img.shields.io/github/workflow/status/njasm/blunt/CI/master?style=for-the-badge\" height=\"20\"\u003e](https://github.com/njasm/blunt/actions?query=branch%3Amaster)\n\nHighly opinionated way to build asynchronous Websocket servers with Rust\n\n### How\n\nThe world famous example, echo server\n```rust\n#[tokio::main]\nasync fn main() -\u003e Result\u003c()\u003e {\n    ::blunt::builder()\n        .for_path_with_ctor(\"/echo\", |ctx| EchoServer { ctx })\n        .build()\n        .bind(\"127.0.0.1:3000\".parse().expect(\"Invalid Socket Addr\"))\n        .await?;\n\n    Ok(())\n    \n    // now connect your clients to http://127.0.0.1:3000/echo and say something!\n}\n\n#[derive(Debug, Default)]\npub struct EchoServer {\n    ctx: AppContext,\n}\n\n#[blunt::async_trait]\nimpl WebSocketHandler for EchoServer {\n    async fn on_open(\u0026mut self, session_id: Uuid) {\n        self.ctx\n            .session(session_id)\n            .await\n            .and_then(|s| {\n                s.send(WebSocketMessage::Text(String::from(\n                    \"Welcome to Echo server!\",\n                ))).ok()\n            });\n    }\n\n    async fn on_message(\u0026mut self, session_id: Uuid, msg: WebSocketMessage) {\n        self.ctx\n            .session(session_id)\n            .await\n            .and_then(|s| s.send(msg).ok());\n    }\n\n    async fn on_close(\u0026mut self, session_id: Uuid, _msg: WebSocketMessage) {\n        info!(\"connection closed for session id {}\", session_id);\n    }\n}\n```\nFor more code examples please see the \u003ca href=\"examples/\"\u003eexamples\u003c/a\u003e folder.\n\n### License\n\nTri-Licensed under either of \u003ca href=\"LICENSE-APACHE-2.0\"\u003eApache License, Version\n2.0\u003c/a\u003e, \u003ca href=\"LICENSE-MIT\"\u003eMIT license\u003c/a\u003e or \u003ca href=\"LICENSE-MPL-2.0\"\u003eMPL-2.0 license\u003c/a\u003e at your option.\n\u003cbr\u003e\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in this crate by you, as defined in the Apache-2.0 license, shall\nbe tri-licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnjasm%2Fblunt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnjasm%2Fblunt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnjasm%2Fblunt/lists"}