{"id":20606023,"url":"https://github.com/martinitus/osgiliath-rs","last_synced_at":"2025-09-23T18:46:57.247Z","repository":{"id":84288478,"uuid":"531445624","full_name":"martinitus/osgiliath-rs","owner":"martinitus","description":"A prototype rust macro bridging `tower::Service` with `async_trait`.","archived":false,"fork":false,"pushed_at":"2022-09-03T15:36:15.000Z","size":8,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-17T02:35:19.662Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/martinitus.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2022-09-01T09:16:14.000Z","updated_at":"2022-09-07T06:09:32.000Z","dependencies_parsed_at":"2023-05-11T10:15:47.094Z","dependency_job_id":null,"html_url":"https://github.com/martinitus/osgiliath-rs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinitus%2Fosgiliath-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinitus%2Fosgiliath-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinitus%2Fosgiliath-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinitus%2Fosgiliath-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/martinitus","download_url":"https://codeload.github.com/martinitus/osgiliath-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242250926,"owners_count":20096897,"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-16T09:32:07.711Z","updated_at":"2025-09-23T18:46:52.213Z","avatar_url":"https://github.com/martinitus.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Osgiliath\n\nBridges the Anduin between the towers...\n\n__Disclaimer: The author of this repository is fairly new with Rust (especially macros)\na lot of the implementation may be plain wrong or violate best practices. The idea \nof this repository is to demonstrate that it's possible and eventually gather feedback\nfrom the community.__\n\nThis repository contains a __prototype__ macro that generates code allowing to use\n`async traits` (via [async_trait crate](https://github.com/dtolnay/async-trait))\nas [tower's](https://github.com/tower-rs/tower) `tower::Service` and vice versa.\n\nThe goals of this are two fold:\n - easily use of any tower layers (timeout, rate limits, ...) with async traits.\n - prototype external services quickly as part of the application via `tower::Service`\n   which eventually can be replaced with clients. \n\nThe idea is to enable the following without having to write any glue code:\n\n```rust\nuse async_trait::async_trait;\nuse osgiliath::tower_service;\nuse tower::Service;\n\n#[tower_service] // includes #[async_trait]\ntrait TheTrait: Send {\n    async fn bla(\u0026mut self, value1: String, value2: usize);\n    async fn blub(\u0026mut self) -\u003e f32;\n}\n\nstruct TheStruct;\n\n#[async_trait]\nimpl TheTrait for TheStruct {\n    async fn bla(\u0026mut self, _value1: String, _value2: usize) {}\n    async fn blub(\u0026mut self) -\u003e f32 { return 4.20; }\n}\n\nfn use_as_trait(_s: \u0026dyn TheTrait) {}\n\nfn use_as_service(_s: \u0026impl Service\u003cTheTraitRequest\u003e) {}\n\nfn main() {\n    // instantiate a wrapper around TheStruct that implements tower::Service\n    let service = TheTraitService::new(TheStruct {});\n    use_as_service(\u0026service);\n    // any Service\u003cTheTraitRequest\u003e also implements the original trait\n    use_as_trait(\u0026service);\n}\n```\n\n## Acknowledgments\nThis example would not have been possible without the excellent documentation of the\n`syn`, `quote`, `async_trait`, and `proc_macro2` crates as well as the \n[macro workshop template repository](https://github.com/dtolnay/proc-macro-workshop).  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartinitus%2Fosgiliath-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmartinitus%2Fosgiliath-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartinitus%2Fosgiliath-rs/lists"}