{"id":17991887,"url":"https://github.com/dspicher/ur-rs","last_synced_at":"2025-04-09T13:05:48.109Z","repository":{"id":36950855,"uuid":"294458240","full_name":"dspicher/ur-rs","owner":"dspicher","description":"A Rust implementation of Uniform Resources","archived":false,"fork":false,"pushed_at":"2025-02-20T08:29:10.000Z","size":313,"stargazers_count":20,"open_issues_count":1,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T06:52:33.488Z","etag":null,"topics":["rust","uniform-resources"],"latest_commit_sha":null,"homepage":"","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/dspicher.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-10T16:06:02.000Z","updated_at":"2025-02-20T08:29:08.000Z","dependencies_parsed_at":"2024-02-01T13:45:37.847Z","dependency_job_id":"91e5bfd8-0875-42bd-b30c-37b4f923f22c","html_url":"https://github.com/dspicher/ur-rs","commit_stats":{"total_commits":290,"total_committers":5,"mean_commits":58.0,"dds":0.3448275862068966,"last_synced_commit":"d991c9d95e05a128933d919169b60d51d57d1d0b"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dspicher%2Fur-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dspicher%2Fur-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dspicher%2Fur-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dspicher%2Fur-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dspicher","download_url":"https://codeload.github.com/dspicher/ur-rs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248045231,"owners_count":21038553,"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","uniform-resources"],"created_at":"2024-10-29T19:24:36.614Z","updated_at":"2025-04-09T13:05:48.086Z","avatar_url":"https://github.com/dspicher.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"Rust Uniform Resources\n======================\n[\u003cimg alt=\"build status\" src=\"https://img.shields.io/github/actions/workflow/status/dspicher/ur-rs/rust.yml?branch=master\u0026logo=github\" height=\"20\"\u003e](https://github.com/dspicher/ur-rs/actions)\n[\u003cimg alt=\"build status\" src=\"https://img.shields.io/codecov/c/gh/dspicher/ur-rs?logo=codecov\" height=\"20\"\u003e](https://codecov.io/gh/dspicher/ur-rs)\n[\u003cimg alt=\"build status\" src=\"https://img.shields.io/crates/v/ur.svg\" height=\"20\"\u003e](https://crates.io/crates/ur)\n[![dependency status](https://deps.rs/repo/github/dspicher/ur-rs/status.svg)](https://deps.rs/repo/github/dspicher/ur-rs)\n\n\u003c!-- cargo-rdme start --\u003e\n\n`ur` is a crate to interact with [`uniform resource`](https://github.com/BlockchainCommons/Research/blob/master/papers/bcr-2020-005-ur.md) encodings of binary data.\nThe encoding scheme is optimized for transport in URIs and QR codes.\n\nThe [`ur::Encoder`] allows a byte payload to be transmissioned in\nmultiple stages, respecting maximum size requirements. Under the hood,\na [`fountain`](https://en.wikipedia.org/wiki/Fountain_code) encoder is used to create an unbounded stream of URIs,\nsubsets of which can be recombined at the receiving side into the payload:\n```rust\nlet data = String::from(\"Ten chars!\").repeat(10);\nlet max_length = 5;\nlet mut encoder = ur::Encoder::bytes(data.as_bytes(), max_length).unwrap();\nlet part = encoder.next_part().unwrap();\nassert_eq!(\n    part,\n    \"ur:bytes/1-20/lpadbbcsiecyvdidatkpfeghihjtcxiabdfevlms\"\n);\nlet mut decoder = ur::Decoder::default();\nwhile !decoder.complete() {\n    let part = encoder.next_part().unwrap();\n    // Simulate some communication loss\n    if encoder.current_index() \u0026 1 \u003e 0 {\n        decoder.receive(\u0026part).unwrap();\n    }\n}\nassert_eq!(decoder.message().unwrap().as_deref(), Some(data.as_bytes()));\n```\n\nThe following useful building blocks are also part of the public API:\n - The [`crate::bytewords`](https://docs.rs/ur/latest/ur/bytewords/) module contains functionality\n   to encode byte payloads into a suitable alphabet, achieving hexadecimal\n   byte-per-character efficiency.\n - The [`crate::fountain`](https://docs.rs/ur/latest/ur/fountain/) module provides an implementation\n   of a fountain encoder, which splits up a byte payload into multiple segments\n   and emits an unbounded stream of parts which can be recombined at the receiving\n   decoder side.\n\n\u003c!-- cargo-rdme end --\u003e\n\n## Usage\n\nAdd `ur` to the dependencies of your `Cargo.toml`:\n```shell\ncargo add ur\n```\n\n## Examples\n\n### Animated QR code\nTo run this example, execute\n```bash\ncargo run --example qr -- \"This is my super awesome UR payload\"\n```\nwhich will print out URIs and QR codes transmitting the provided payload.\n\n## Background: Uniform Resources\n[Uniform Resources](https://github.com/BlockchainCommons/Research/blob/master/papers/bcr-2020-005-ur.md) are\n\u003e a proposed method of encoding binary data of arbitrary content and length so that it is suitable for transport in either URIs or QR codes.\n\nThe resulting constraints on the permissible encoding alphabet are nicely analyzed [here](https://github.com/BlockchainCommons/Research/blob/master/papers/bcr-2020-003-uri-binary-compatibility.md).\n\nThe following building blocks interact to achieve this goal:\n- [Bytewords](https://github.com/BlockchainCommons/Research/blob/master/papers/bcr-2020-012-bytewords.md) map binary data to case-insensitive characters with a 4 bits/char efficiency (identical to hexadecimal encoding)\n- Fragments for transmitting multi-part messages are constructed based on a [Luby transform](https://en.wikipedia.org/wiki/Luby_transform_code) (a particular kind of [fountain encoding](https://en.wikipedia.org/wiki/Fountain_code)), generating a potentially limitless sequence of fragments, small subsets of which can restore the original message\n- [CBOR](https://tools.ietf.org/html/rfc7049) allows for self-describing byte payloads\n- A properly seeded [Xoshiro](https://en.wikipedia.org/wiki/Xorshift#xoshiro_and_xoroshiro) pseudo-random generator allows the encoding and decoding parties to agree on which message parts were combined into a fountain encoding fragment\n\n## Other implementations\nThis Rust implementation, in particular its test vectors, is based on the following reference implementations:\n- C++: [bc-ur](https://github.com/BlockchainCommons/bc-ur/)\n- Swift: [URKit](https://github.com/blockchaincommons/URKit)\n\n## Contributing\nPull requests are welcome.\n\n## License\nThis project is licensed under the terms of the [MIT](https://choosealicense.com/licenses/mit/) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdspicher%2Fur-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdspicher%2Fur-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdspicher%2Fur-rs/lists"}