{"id":18672190,"url":"https://github.com/fizyr/fizyr-rpc","last_synced_at":"2025-04-12T01:30:56.558Z","repository":{"id":40414181,"uuid":"293876087","full_name":"fizyr/fizyr-rpc","owner":"fizyr","description":"Native Rust implementation of the Fizyr RPC protocol","archived":false,"fork":false,"pushed_at":"2023-12-11T09:41:22.000Z","size":426,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-09T17:47:22.094Z","etag":null,"topics":["hacktoberfest","rpc","rust","shared-memory"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fizyr.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-09-08T17:08:28.000Z","updated_at":"2025-04-07T12:08:18.000Z","dependencies_parsed_at":"2023-12-04T10:27:51.581Z","dependency_job_id":"258a37a2-4c47-48a5-94e4-0044ed6b9d6f","html_url":"https://github.com/fizyr/fizyr-rpc","commit_stats":{"total_commits":290,"total_committers":5,"mean_commits":58.0,"dds":0.05862068965517242,"last_synced_commit":"7f7c877d63e5902939b1b50f514a4e05415b24c9"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fizyr%2Ffizyr-rpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fizyr%2Ffizyr-rpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fizyr%2Ffizyr-rpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fizyr%2Ffizyr-rpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fizyr","download_url":"https://codeload.github.com/fizyr/fizyr-rpc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248504212,"owners_count":21115134,"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":["hacktoberfest","rpc","rust","shared-memory"],"created_at":"2024-11-07T09:09:56.967Z","updated_at":"2025-04-12T01:30:56.042Z","avatar_url":"https://github.com/fizyr.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Docs.rs](https://docs.rs/fizyr-rpc/badge.svg)](https://docs.rs/fizyr-rpc/)\n[![Tests](https://github.com/fizyr-private/fizyr-rpc-rs/workflows/tests/badge.svg)](https://github.com/fizyr/fizyr-rpc-rs/actions?query=workflow%3Atests+branch%3Amain)\n\n# fizyr-rpc\n\nRust implementation of the Fizyr RPC procotol.\n\nThe Fizyr RPC protocol is a request/response protocol,\nwith bi-directional feedback as long as a request is open.\nAdditionally, you can send individual stream messages that do not initiate a request.\n\n## Overview\n\n### Peer and PeerHandle\n\nAs a user of the library, you will mostly be using the [`PeerHandle`] object.\nThe [`PeerHandle`] is used to interact with a remote peer.\nIt is used to send and receive requests and stream messages.\nIt can also be split in a [`PeerReadHandle`] and a [`PeerWriteHandle`],\nto allow moving the handles into different tasks.\nThe write handle can also be cloned and used in multiple tasks.\n\nTo obtain a [`PeerHandle`], you can call [`Peer::connect()`].\nThis will connect to a remote listener and spawn a background task to read and write messages over the connection.\nIf you need full control over tasks, you can instead create a [`Peer`] object\nand call [`Peer::run()`] manually.\n\n### Listener\n\nThe [`Listener`] struct is used to accept incoming connections\nand gives you a [`PeerHandle`] for each incoming connection.\nYou can then use the handle to process incoming messages and to send messages to the peer.\nUsually, you will want to spawn a task for each accepted connection that handles the communication.\n\n### Transports\n\nEach peer internally uses a [`Transport`][transport::Transport].\nThe transport is responsible for reading and writing raw messages.\nBy abstracting away the message transport,\nthe library can expose a single generic [`Peer`] and [`Listener`] struct.\n\nThere are different transports for different socket types.\nDifferent transports may also use different types as message body.\nFor example, the [`TcpTransport`] and [`UnixStreamTransport`]\nuse messages with a [`StreamBody`].\nThis [`StreamBody`] body type contains raw bytes.\n\nThe [`UnixSeqpacketTransport`] has messages with a [`UnixBody`],\nwhich allows you to embed file descriptors with each message.\n\n## Features\n\nThe library uses features to avoid unnecessarily large dependency trees.\nEach feature corresponds to a different transport type.\nNone of the features are enabled by default.\nCurrently, the library has these features:\n\n* `tcp`: for the [`TcpTransport`]\n* `unix-stream`: for the [`UnixStreamTransport`]\n* `unix-seqpacket`: for the [`UnixSeqpacketTransport`]\n\n## Example\n\n```rust\nuse fizyr_rpc::{TcpPeer, StreamConfig};\n\nlet (peer, info) = TcpPeer::connect(\"localhost:1337\", StreamConfig::default()).await?;\neprintln!(\"Connected to: {}\", info.remote_address());\nlet mut request = peer.send_request(1, \u0026b\"Hello World!\"[..]).await?;\n\nwhile let Some(update) = request.recv_update().await {\n    let body = std::str::from_utf8(\u0026update.body)?;\n    eprintln!(\"Received update: {}\", body);\n}\n\nlet response = request.recv_response().await?;\nlet body = std::str::from_utf8(\u0026response.body)?;\neprintln!(\"Received response: {}\", body);\n```\n\n[`Peer`]: https://docs.rs/fizyr-rpc/latest/fizyr_rpc/struct.Peer.html\n[`Peer::connect()`]: https://docs.rs/fizyr-rpc/latest/fizyr_rpc/struct.Peer.html#method.connect\n[`Peer::run()`]: https://docs.rs/fizyr-rpc/latest/fizyr_rpc/struct.Peer.html#method.run\n[`PeerHandle`]: https://docs.rs/fizyr-rpc/latest/fizyr_rpc/struct.PeerHandle.html\n[`PeerReadHandle`]: https://docs.rs/fizyr-rpc/latest/fizyr_rpc/struct.PeerReadHandle.html\n[`PeerWriteHandle`]: https://docs.rs/fizyr-rpc/latest/fizyr_rpc/struct.PeerWriteHandle.html\n[`Server`]: https://docs.rs/fizyr-rpc/latest/fizyr_rpc/struct.Server.html\n\n[transport::Transport]: https://docs.rs/fizyr-rpc/latest/fizyr_rpc/transport/trait.Transport.html\n[`TcpTransport`]: https://docs.rs/fizyr-rpc/latest/fizyr_rpc/type.TcpTransport.html\n[`UnixStreamTransport`]: https://docs.rs/fizyr-rpc/latest/fizyr_rpc/type.UnixStreamTransport.html\n[`UnixSeqpacketTransport`]: https://docs.rs/fizyr-rpc/latest/fizyr_rpc/type.UnixSeqpacketTransport.html\n\n[`StreamBody`]: https://docs.rs/fizyr-rpc/latest/fizyr_rpc/struct.StreamBody.html\n[`UnixBody`]: https://docs.rs/fizyr-rpc/latest/fizyr_rpc/struct.UnixBody.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffizyr%2Ffizyr-rpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffizyr%2Ffizyr-rpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffizyr%2Ffizyr-rpc/lists"}