{"id":19078780,"url":"https://github.com/elasticrash/udp_polygon","last_synced_at":"2025-06-27T02:33:58.870Z","repository":{"id":182588269,"uuid":"667980160","full_name":"elasticrash/udp_polygon","owner":"elasticrash","description":"An opinionated udp library ","archived":false,"fork":false,"pushed_at":"2023-11-27T15:29:42.000Z","size":58,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-15T18:18:30.696Z","etag":null,"topics":["rust","rust-lib","rust-library","udp"],"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/elasticrash.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":"2023-07-18T18:30:37.000Z","updated_at":"2023-10-05T07:36:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"daef4da9-f185-48e5-a75e-711982e6a347","html_url":"https://github.com/elasticrash/udp_polygon","commit_stats":null,"previous_names":["elasticrash/upd_polygon"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/elasticrash/udp_polygon","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elasticrash%2Fudp_polygon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elasticrash%2Fudp_polygon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elasticrash%2Fudp_polygon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elasticrash%2Fudp_polygon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elasticrash","download_url":"https://codeload.github.com/elasticrash/udp_polygon/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elasticrash%2Fudp_polygon/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260288745,"owners_count":22986731,"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":["rust","rust-lib","rust-library","udp"],"created_at":"2024-11-09T02:11:55.420Z","updated_at":"2025-06-27T02:33:58.823Z","avatar_url":"https://github.com/elasticrash.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# UDP Polygon\n\nAn opiniated UDP listener and publisher\n\n## Breaking Changes\nFrom 0.1.1 to 0.2.0\nPreviously, versions below 0.1.1 were converting the received datagram bytes into a string. However, starting from version 0.2.0 and onwards, the receive event now delivers the bytes directly.\nAdditionally, the expected format for sending data now requires it to be encapsulated within a Vec\u003cu8\u003e for compatibility.\nThe change was implemented because the previous implementation was found to be too restrictive.\n\n## Requirements\n\n* the consumer requires tokio\n* a producer does not require anything extra\n* a producer with the timer flag enabled requires tokio\n\n## Configuration\n\nThere are many options on configuring your UDP client and server\n\n* TOML file\n``` Toml\n[[bind_addresses]]\nip = \"127.0.0.1\"\nport = 5061\n[destination_address]\nip = \"127.0.0.1\"\nport = 5060\n```\n* Arguments\n\n``` rust\n let config = Config::from_arguments(\n        vec![(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 5061)],\n        Some((IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 5060)),\n    );\n```\n\n* Enviroment variables\n\n``` bash \nexport BIND_ADDRS=127.0.0.1\nexport BIND_PORT=5061\nexport DEST_ADDRS=127.0.0.1\nexport DEST_PORT=5060\n```\n\n``` rust\n let config = Config::from_env();\n```\n\n## Send\n\n``` rust \n    polygon.send(\"Hello World\".as_bytes().to_vec());\n``` \n\n## Receive\n\n``` rust\n    let rx = polygon.receive();\n \n    loop {\n        let maybe = rx.try_recv();\n        if let Ok(data) = maybe {\n            println!(\"receiving... {data:?}\");\n        }\n    }\n```\n\n## Basic Examples\n\n* send_fa (example by passing arguments)\n* receive_fa (example by passing arguments)\n* send_toml (example by using a toml file)\n* receive_toml (example by using a toml file)\n* send_receive (both sending and receiving)\n\n## Timer flag\n\nRetransmits a message with specific delays \n\n``` rust\n  polygon.send_with_timer(\n        \"Hello World\".as_bytes().to_vec(),\n        Timers {\n            delays: vec![500, 600, 1000, 1500],\n        },\n    );\n\n```\n\nretransmissions can be paused at any given time, even mid sending a message, effectively cancelling a retransmission\n\n``` rust\n    let mut polygon = Polygon::configure(config);\n    let pause = Arc::clone(\u0026polygon.pause_timer_send);\n    *pause.lock().unwrap() = true;\n```\nor \n``` rust\n    let mut polygon = Polygon::configure(config);\n    polygon.pause_timer_send()\n    polygon.resume_timer_send()\n```\nthis will make the send_with_timer to behave like a normal send (only it would still require tokio)\n\n## Timer Examples\n* send_receive_with_timer\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felasticrash%2Fudp_polygon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felasticrash%2Fudp_polygon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felasticrash%2Fudp_polygon/lists"}