{"id":28384394,"url":"https://github.com/polyphony-chat/pubserve","last_synced_at":"2025-10-12T22:38:38.539Z","repository":{"id":248249159,"uuid":"828023624","full_name":"polyphony-chat/pubserve","owner":"polyphony-chat","description":"Simple, generic observer trait.","archived":false,"fork":false,"pushed_at":"2024-08-03T09:18:52.000Z","size":32,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-06-25T23:35:21.068Z","etag":null,"topics":["design-patterns","observer-pattern","rust"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/pubserve","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/polyphony-chat.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":"2024-07-12T23:07:02.000Z","updated_at":"2025-06-19T04:10:17.000Z","dependencies_parsed_at":"2024-08-03T10:31:25.469Z","dependency_job_id":"d42d3bf1-22f5-48b7-8601-0bebd76e26bc","html_url":"https://github.com/polyphony-chat/pubserve","commit_stats":null,"previous_names":["polyphony-chat/pubserve"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/polyphony-chat/pubserve","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polyphony-chat%2Fpubserve","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polyphony-chat%2Fpubserve/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polyphony-chat%2Fpubserve/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polyphony-chat%2Fpubserve/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/polyphony-chat","download_url":"https://codeload.github.com/polyphony-chat/pubserve/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polyphony-chat%2Fpubserve/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279013278,"owners_count":26085250,"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","status":"online","status_checked_at":"2025-10-12T02:00:06.719Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["design-patterns","observer-pattern","rust"],"created_at":"2025-05-30T08:30:23.502Z","updated_at":"2025-10-12T22:38:38.534Z","avatar_url":"https://github.com/polyphony-chat.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003e [!IMPORTANT]\n\u003e 📦️ We moved! Come check out our new place over on [Codeberg](https://codeberg.org/polyphony)! ([Repository link](https://codeberg.org/polyphony/pubserve))\n\u003e\n\u003e We have moved to [Codeberg](https://codeberg.org/polyphony) as our primary Git Forge, and the project is *alive and well* over there! :purple_heart: The GitHub repositories will be archived and potentially deleted in the future.\n\n# pubserve\n\n\u003e Publish and observe.\n\nSimple, generic observer pattern implementation for Rust.\n\n## Usage\n\npubserve is really simple to use. Start by creating a `Publisher` for your data type:\n\n```rust\nuse pubserve::Publisher;\n\nlet publisher = Publisher::\u003ci32\u003e::new();\n```\n\nThen, create a subscriber that will listen to the publisher:\n\n```rust\nuse pubserve::Subscriber;\n\nstruct MySubscriber;\n\nimpl Subscriber\u003ci32\u003e for MySubscriber {\n    fn update(\u0026self, message: \u0026i32) {\n        // Do whatever you want with the data!\n        println!(\"Received data: {}\", message);\n    }\n}\n```\n\nFinally, subscribe the observer to the publisher:\n\n```rust\nuse pubserve::ReferenceCounted;\n\nlet observer = MySubscriber;\nlet reference = ReferenceCounted::new(\u0026observer);\npublisher.subscribe(reference);\n```\n\nNow, whenever you publish data, all subscribed observers will be notified:\n\n```rust\npublisher.publish(42);\n// STDOUT: \"Received data: 42\"\n```\n\nUnsubscribing is just as easy:\n\n```rust\npublisher.unsubscribe(reference);\npublisher.publish(42);\n// Nothing will be printed\n```\n\nIt is of course possible to have multiple implementations of `Subscriber` be subscribed to the\nsame `Publisher`. All of them will be notified immediately when data is published.\n\n## Features\n\nNo features are enabled by default. The following features are available:\n\n| Feature | Description                                                                                                                                                                         |\n| ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `send`  | Makes the `Subscriber` trait `Send` and thus thread-safe.                                                                                                                           |\n| `async` | Makes the `Subscriber` trait `Sync` and `async` via the [`async_trait` crate](https://crates.io/crates/async-trait). Additionally, makes the publishing method `async` by extension |\n\nThe `send` and `async` features can both be enabled at the same time, but do not have to be, should\nyou only need one of them.\n\n## License\n\nThis project is licensed under the MPL-2.0 license. See the [LICENSE](LICENSE) file for more information.\nBy committing to this repository, you agree to license your contributions under the MPL-2.0 license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpolyphony-chat%2Fpubserve","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpolyphony-chat%2Fpubserve","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpolyphony-chat%2Fpubserve/lists"}