{"id":19982053,"url":"https://github.com/khonsulabs/ordered-varint","last_synced_at":"2025-05-04T05:32:12.474Z","repository":{"id":57479144,"uuid":"433289354","full_name":"khonsulabs/ordered-varint","owner":"khonsulabs","description":"Variable-length signed and unsigned integer encoding that is byte-orderable for Rust","archived":false,"fork":false,"pushed_at":"2023-02-01T18:41:31.000Z","size":3085,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-04-24T10:18:06.548Z","etag":null,"topics":["rust-lang","variable-length-encoding"],"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/khonsulabs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE-APACHE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["ecton"]}},"created_at":"2021-11-30T04:13:20.000Z","updated_at":"2023-08-25T01:22:09.000Z","dependencies_parsed_at":"2023-02-17T09:31:16.253Z","dependency_job_id":null,"html_url":"https://github.com/khonsulabs/ordered-varint","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khonsulabs%2Fordered-varint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khonsulabs%2Fordered-varint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khonsulabs%2Fordered-varint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khonsulabs%2Fordered-varint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/khonsulabs","download_url":"https://codeload.github.com/khonsulabs/ordered-varint/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252293082,"owners_count":21724960,"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-lang","variable-length-encoding"],"created_at":"2024-11-13T04:08:54.599Z","updated_at":"2025-05-04T05:32:12.065Z","avatar_url":"https://github.com/khonsulabs.png","language":"Rust","readme":"# ordered-varint\n\nProvides variable-length signed and unsigned integer encoding that is\nbyte-orderable.\n\n[![crate version](https://img.shields.io/crates/v/ordered-varint.svg)](https://crates.io/crates/ordered-varint)\n[![Live Build Status](https://img.shields.io/github/actions/workflow/status/khonsulabs/ordered-varint/tests.yml?branch=main)](https://github.com/khonsulabs/ordered-varint/actions?query=workflow:Tests)\n[![HTML Coverage Report for `main` branch](https://khonsulabs.github.io/ordered-varint/coverage/badge.svg)](https://khonsulabs.github.io/ordered-varint/coverage/)\n[![Documentation for `main` branch](https://img.shields.io/badge/docs-main-informational)](https://khonsulabs.github.io/ordered-varint/main/ordered_varint/)\n\nThis crate provides the `Variable` trait which encodes and decodes integers to\nan abbreviated format that ranges from 1 to 16 bytes. All signed integer types\n(i8, i16, i32, i64, and i128) are comparable with each other, and all unsigned\ninteger types (u8, u16, u32, u64, and u128) are comparable with each other.\n**However, encoded signed and unsigned values are not able to be meaningfully\ncompared to one another.**\n\n## Example\n\nTo run the included example, execute `cargo run --example demo`. The output will\nlook similar to this:\n\n```text\nOriginal bytes: 1968\nEncoded bytes: 1068\n1 encodes as [01]\n3 encodes as [03]\n7 encodes as [07]\n15 encodes as [0f]\n31 encodes as [10, 1f]\n63 encodes as [10, 3f]\n127 encodes as [10, 7f]\n255 encodes as [10, ff]\n511 encodes as [11, ff]\n[...]\n1329227995784915872903807060280344575 encodes as [f0, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff]\n2658455991569831745807614120560689151 encodes as [f1, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff]\n5316911983139663491615228241121378303 encodes as [f3, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff]\n10633823966279326983230456482242756607 encodes as [f7, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff]\n```\n\nAnother example showing signed encoding is available by running `cargo run\n--example demo-signed`. The output will look similar to this:\n\n```text\nOriginal bytes: 3920\nEncoded bytes: 2165\n-5316911983139663491615228241121378305 encodes as [03, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff]\n-2658455991569831745807614120560689153 encodes as [05, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff]\n-1329227995784915872903807060280344577 encodes as [06, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff]\n-664613997892457936451903530140172289 encodes as [07, 7f, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff]\n[...]\n-65 encodes as [77, bf]\n-33 encodes as [77, df]\n-17 encodes as [77, ef]\n-9 encodes as [77, f7]\n-5 encodes as [7b]\n-3 encodes as [7d]\n1 encodes as [81]\n3 encodes as [83]\n7 encodes as [87]\n15 encodes as [88, 0f]\n31 encodes as [88, 1f]\n63 encodes as [88, 3f]\n[...]\n1329227995784915872903807060280344575 encodes as [f8, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff]\n2658455991569831745807614120560689151 encodes as [f9, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff]\n5316911983139663491615228241121378303 encodes as [fb, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff]\n10633823966279326983230456482242756607 encodes as [ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff, ff]\n```\n\n## Open-source Licenses\n\nThis project, like all projects from [Khonsu Labs](https://khonsulabs.com/), are\nopen-source. This repository is available under the [MIT License](./LICENSE-MIT)\nor the [Apache License 2.0](./LICENSE-APACHE).\n\nTo learn more about contributing, please see [CONTRIBUTING.md](./CONTRIBUTING.md).\n","funding_links":["https://github.com/sponsors/ecton"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkhonsulabs%2Fordered-varint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkhonsulabs%2Fordered-varint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkhonsulabs%2Fordered-varint/lists"}