{"id":17007480,"url":"https://github.com/wkhallen/rustdtp","last_synced_at":"2026-02-26T18:07:15.331Z","repository":{"id":50613737,"uuid":"295845809","full_name":"WKHAllen/rustdtp","owner":"WKHAllen","description":"Cross-platform networking interfaces for Rust.","archived":false,"fork":false,"pushed_at":"2024-04-02T23:58:14.000Z","size":176,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-15T05:25:56.366Z","etag":null,"topics":["async","networking","rust","socket","socket-client","socket-server"],"latest_commit_sha":null,"homepage":"https://wkhallen.com/dtp","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/WKHAllen.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}},"created_at":"2020-09-15T20:48:23.000Z","updated_at":"2023-09-12T08:56:55.000Z","dependencies_parsed_at":"2024-10-26T03:52:55.086Z","dependency_job_id":"0478978b-d7bd-4c68-9129-c11bb600dd52","html_url":"https://github.com/WKHAllen/rustdtp","commit_stats":{"total_commits":80,"total_committers":1,"mean_commits":80.0,"dds":0.0,"last_synced_commit":"3659364f8bd504d23ecd09dc75fc45b6c1012793"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WKHAllen%2Frustdtp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WKHAllen%2Frustdtp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WKHAllen%2Frustdtp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WKHAllen%2Frustdtp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WKHAllen","download_url":"https://codeload.github.com/WKHAllen/rustdtp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244952785,"owners_count":20537472,"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":["async","networking","rust","socket","socket-client","socket-server"],"created_at":"2024-10-14T05:25:54.174Z","updated_at":"2026-02-26T18:07:15.325Z","avatar_url":"https://github.com/WKHAllen.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Data Transfer Protocol for Rust\n\nCross-platform networking interfaces for Rust.\n\n## Data Transfer Protocol\n\nThe Data Transfer Protocol (DTP) is a larger project to make ergonomic network programming available in any language. See the full project [here](https://wkhallen.com/dtp/).\n\n## Installation\n\nAdd the package in `Cargo.toml`:\n\n```toml\nrustdtp = \"0.9\"\n```\n\n## Creating a server\n\nA server can be built using the `Server` implementation:\n\n```rust\nuse rustdtp::prelude::*;\n\n#[tokio::main]\nasync fn main() {\n    // Create a server that receives strings and returns the length of each string\n    let (mut server, mut server_events) = Server::builder()\n        .sending::\u003cusize\u003e()\n        .receiving::\u003cString\u003e()\n        .with_event_channel()\n        .start((\"127.0.0.1\", 29275))\n        .await\n        .unwrap();\n\n    // Iterate over events\n    while let Ok(event) = server_events.next().await {\n        match event {\n            ServerEvent::Connect { client_id } =\u003e {\n                println!(\"Client with ID {} connected\", client_id);\n            }\n            ServerEvent::Disconnect { client_id } =\u003e {\n                println!(\"Client with ID {} disconnected\", client_id);\n            }\n            ServerEvent::Receive { client_id, data } =\u003e {\n                // Send back the length of the string\n                server.send(client_id, data.len()).await.unwrap();\n            }\n            ServerEvent::Stop =\u003e {\n                // No more events will be sent, and the loop will end\n                println!(\"Server closed\");\n            }\n        }\n    }\n}\n```\n\n## Creating a client\n\nA client can be built using the `Client` implementation:\n\n```rust\nuse rustdtp::prelude::*;\n\n#[tokio::main]\nasync fn main() {\n    // Create a client that sends a message to the server and receives the length of the message\n    let (mut client, mut client_events) = Client::builder()\n        .sending::\u003cString\u003e()\n        .receiving::\u003cusize\u003e()\n        .with_event_channel()\n        .connect((\"127.0.0.1\", 29275))\n        .await\n        .unwrap();\n\n    // Send a message to the server\n    let msg = \"Hello, server!\".to_owned();\n    client.send(msg.clone()).await.unwrap();\n\n    // Receive the response\n    match client_events.next().await.unwrap() {\n        ClientEvent::Receive { data } =\u003e {\n            // Validate the response\n            println!(\"Received response from server: {}\", data);\n            assert_eq!(data, msg.len());\n        }\n        event =\u003e {\n            // Unexpected response\n            panic!(\"expected to receive a response from the server, instead got {:?}\", event);\n        }\n    }\n}\n```\n\n## Security\n\nInformation security comes included. Every message sent over a network interface is encrypted with AES-256. Diffie-Hellman key exchanges are performed via X25519.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwkhallen%2Frustdtp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwkhallen%2Frustdtp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwkhallen%2Frustdtp/lists"}