{"id":15031271,"url":"https://github.com/chmod77/pusher-rs","last_synced_at":"2026-01-29T02:16:59.806Z","repository":{"id":255266186,"uuid":"849057554","full_name":"chmod77/pusher-rs","owner":"chmod77","description":"The Missing Rustlang pusher crate.","archived":false,"fork":false,"pushed_at":"2024-09-01T00:21:58.000Z","size":114,"stargazers_count":10,"open_issues_count":5,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-27T06:44:04.528Z","etag":null,"topics":["pusher","rust","rustlang"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chmod77.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":"2024-08-28T22:39:30.000Z","updated_at":"2025-05-13T21:20:07.000Z","dependencies_parsed_at":"2024-08-28T23:47:18.068Z","dependency_job_id":"7e9c64eb-b564-409f-8d01-ee41a2de5fae","html_url":"https://github.com/chmod77/pusher-rs","commit_stats":null,"previous_names":["chmod77/pusher-rs"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/chmod77/pusher-rs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chmod77%2Fpusher-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chmod77%2Fpusher-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chmod77%2Fpusher-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chmod77%2Fpusher-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chmod77","download_url":"https://codeload.github.com/chmod77/pusher-rs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chmod77%2Fpusher-rs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28860681,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T22:56:21.783Z","status":"online","status_checked_at":"2026-01-29T02:00:06.714Z","response_time":59,"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":["pusher","rust","rustlang"],"created_at":"2024-09-24T20:15:19.322Z","updated_at":"2026-01-29T02:16:59.791Z","avatar_url":"https://github.com/chmod77.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Welcome to `pusher_rs` - The long-missing Rust Pusher crate.\n\n    This library is still under heavy development. Currently in use by one of the projects I am working on. \n    \n    Open-sourcing it since it has matured to a good level. \n\nA Rust client library for interacting with the Pusher Channels API. This library provides a simple and efficient way to integrate Pusher's real-time functionality into your Rust applications.\n\n## Features\n\n- [x] Connect to Pusher Channels\n- [x] Subscribe to public, private, presence, and private encrypted channels\n- [x] Publish events to channels\n- [x] Handle incoming events\n- [x] Automatic reconnection with exponential backoff\n- [x] Environment-based configuration\n- [x] Flexible channel management\n- [x] Support for Batch Triggers\n\n### Todo\n- [ ] Improve error handling and logging\n- [ ] Add comprehensive test suite\n- [ ] Implement WebHooks support\n- [ ] Optimize performance for high-load scenarios\n- [ ] Create more detailed documentation and examples\n\n## Installation\n\nAdd this to your `Cargo.toml`:\n\n```toml\n[dependencies]\npusher-rs = \"0.1.2\"\n```\n\nIf you want to use a specific branch or commit, you can specify it like this:\n```toml\n[dependencies]\npusher-rs = { git = \"https://github.com/username/pusher-rs.git\", branch = \"main\" }\n# or\npusher-rs = { git = \"https://github.com/username/pusher-rs.git\", rev = \"commit_hash\" }\n```\n\n## Configuration\n\nThe library uses environment variables for configuration. Create a `.env` file in your project root with the following variables:\n\n```\nPUSHER_APP_ID=your_app_id\nPUSHER_KEY=your_app_key\nPUSHER_SECRET=your_app_secret\nPUSHER_CLUSTER=your_cluster\nPUSHER_USE_TLS=true - this will enforce TLS\n```\n\n## Usage\n\n### Initializing the client\n\n```rust\nuse pusher_rs::{PusherClient, PusherConfig};\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    let config = PusherConfig::from_env()?;\n    let mut client = PusherClient::new(config)?;\n\n    // PusherClient::new(config).unwrap()\n    \n    client.connect().await?;\n\n    Ok(())\n}\n```\n\n\n### Connecting\n\nConnect to Pusher:\n\n```rust\nclient.connect().await?;\n```\n\n### Subscribing to Channels\n\nSubscribe to a public channel:\n\n```rust\nclient.subscribe(\"my-channel\").await?;\n```\n\nSubscribe to a private channel:\n\n```rust\nclient.subscribe(\"private-my-channel\").await?;\n```\n\nSubscribe to a presence channel:\n\n```rust\nclient.subscribe(\"presence-my-channel\").await?;\n```\n\n### Unsubscribing from Channels\n\n```rust\nclient.unsubscribe(\"my-channel\").await?;\n```\n\n### Binding to Events\n\nBind to a specific event on a channel:\n\n```rust\nuse pusher_rs::Event;\n\nclient.bind(\"my-event\", |event: Event| {\n    println!(\"Received event: {:?}\", event);\n}).await?;\n```\n\n### Subscribing to a channel\n\n```rust\nclient.subscribe(\"my-channel\").await?;\n```\n\n### Publishing an event\n\n```rust\nclient.trigger(\"my-channel\", \"my-event\", \"Hello, Pusher!\").await?;\n```\n\n### Publishing batch events\n\n```rust\nuse pusher_rs::BatchEvent;\n\nlet batch_events = vec![\n    BatchEvent {\n        channel: \"channel-1\".to_string(),\n        event: \"event-1\".to_string(),\n        data: \"{\\\"message\\\": \\\"Hello from event 1\\\"}\".to_string(),\n    },\n    BatchEvent {\n        channel: \"channel-2\".to_string(),\n        event: \"event-2\".to_string(),\n        data: \"{\\\"message\\\": \\\"Hello from event 2\\\"}\".to_string(),\n    },\n];\n\nclient.trigger_batch(batch_events).await?;\n```\n\n### Handling events\n\n```rust\nclient.bind(\"my-event\", |event| {\n    println!(\"Received event: {:?}\", event);\n}).await?;\n```\n\n### Working with encrypted channels\n\n```rust\n// Subscribe to an encrypted channel\nclient.subscribe_encrypted(\"private-encrypted-channel\").await?;\n\n// Publish to an encrypted channel\nclient.trigger_encrypted(\"private-encrypted-channel\", \"my-event\", \"Secret message\").await?;\n```\n\n## Channel Types\n\nThe library supports four types of channels:\n\n- Public\n- Private\n- Presence\n- Private Encrypted\n\nEach channel type has specific features and authentication requirements.\n\n### Handling Connection State\n\nGet the current connection state:\n\n```rust\nlet state = client.get_connection_state().await;\nprintln!(\"Current connection state: {:?}\", state);\n```\n\n## Error Handling\n\nThe library uses a custom `PusherError` type for error handling. You can match on different error variants to handle specific error cases:\n\n```rust\nuse pusher_rs::PusherError;\n\nmatch client.connect().await {\n    Ok(_) =\u003e println!(\"Connected successfully\"),\n    Err(PusherError::ConnectionError(e)) =\u003e println!(\"Connection error: {}\", e),\n    Err(PusherError::AuthError(e)) =\u003e println!(\"Authentication error: {}\", e),\n    Err(e) =\u003e println!(\"Other error: {}\", e),\n}\n```\n\n### Disconnecting\n\nWhen you're done, disconnect from Pusher:\n\n```rust\nclient.disconnect().await?;\n```\n\n## Advanced Usage\n\n### Custom Configuration\n\nWhile the library defaults to using environment variables, you can also create a custom configuration:\n\n```rust\nuse pusher_rs::PusherConfig;\nuse std::time::Duration;\n\nlet config = PusherConfig {\n    app_id: \"your_app_id\".to_string(),\n    app_key: \"your_app_key\".to_string(),\n    app_secret: \"your_app_secret\".to_string(),\n    cluster: \"your_cluster\".to_string(),\n    use_tls: true,\n    host: Some(\"custom.pusher.com\".to_string()),\n    max_reconnection_attempts: 10,\n    backoff_interval: Duration::from_secs(2),\n    activity_timeout: Duration::from_secs(180),\n    pong_timeout: Duration::from_secs(45),\n};\n```\n\n### Channel Management\n\nThe library provides a `ChannelList` struct for managing subscribed channels:\n\n```rust\nlet mut channel_list = ChannelList::new();\nlet channel = Channel::new(\"my-channel\");\nchannel_list.add(channel);\n\nif let Some(channel) = channel_list.get(\"my-channel\") {\n    println!(\"Channel type: {:?}\", channel.channel_type());\n}\n```\n\n### Presence Channels\n\nWhen subscribing to a presence channel, you can provide user information:\n\n```rust\nuse serde_json::json;\n\nlet channel = \"presence-my-channel\";\nlet socket_id = client.get_socket_id().await?;\nlet user_id = \"user_123\";\nlet user_info = json!({\n    \"name\": \"John Doe\",\n    \"email\": \"john@example.com\"\n});\n\nlet auth = client.authenticate_presence_channel(\u0026socket_id, channel, user_id, Some(\u0026user_info))?;\nclient.subscribe_with_auth(channel, \u0026auth).await?;\n```\n\n### Tests\n\nIntegration tests live under `tests/integration_tests`\n\nJust run `cargo test --test integration_tests -- --nocapture` to start.\n\nMore tests are being added. This section will be updated accordingly.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request. Here's how you can contribute:\n\n- [x] Fork the repository\n- [x] Create your feature branch (`git checkout -b feat/amazing-feature`)\n- [x] Commit your changes (`git commit -m 'feat: Add some amazing feature'`)\n- [x] Push to the branch (`git push origin feat/amazing-feature`)\n- [x] Open a Pull Request\n\n## License\n\nThis project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchmod77%2Fpusher-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchmod77%2Fpusher-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchmod77%2Fpusher-rs/lists"}