{"id":21928141,"url":"https://github.com/depp/bytesize-rs","last_synced_at":"2025-10-25T02:48:52.380Z","repository":{"id":48125363,"uuid":"516540940","full_name":"depp/bytesize-rs","owner":"depp","description":"Format data sizes for humans","archived":false,"fork":false,"pushed_at":"2022-07-22T04:37:27.000Z","size":13,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-22T12:18:54.449Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/depp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-21T22:41:41.000Z","updated_at":"2022-10-02T08:45:36.000Z","dependencies_parsed_at":"2022-09-04T01:41:26.434Z","dependency_job_id":null,"html_url":"https://github.com/depp/bytesize-rs","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/depp/bytesize-rs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/depp%2Fbytesize-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/depp%2Fbytesize-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/depp%2Fbytesize-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/depp%2Fbytesize-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/depp","download_url":"https://codeload.github.com/depp/bytesize-rs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/depp%2Fbytesize-rs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272497404,"owners_count":24944680,"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","status":"online","status_checked_at":"2025-08-28T02:00:10.768Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-11-28T22:21:28.994Z","updated_at":"2025-10-25T02:48:47.337Z","avatar_url":"https://github.com/depp.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ByteSize (Rust)\n\n**Simple** and **correct.**\n\nByteSize is a Rust library for formatting and parsing numbers as byte sizes for humans. Numbers are formatted with three digits of precision, using SI prefixes, and the unit “B” for bytes. For example, 1000 is formatted as “1.00 KB”. The numbers are rounded using round-to-even, which is the familiar method used by `std::fmt`.\n\nThere are no choices to make. ByteSize is not configurable.\n\nThis library is also available for Go: https://github.com/depp/bytesize\n\n## Formatting\n\nThe precision cannot be changed. Non-decimal prefixes are not produced: no kibibytes, no powers of two. Wrap the number in the `ByteSize` struct and print it with `std::fmt`.\n\n```rust\n/// A byte size which is displayed using SI prefixes.\n#[derive(Debug, Clone, Copy, PartialEq, Eq)]\npub struct ByteSize(pub u64);\n```\n\nAll corner cases should be handled correctly and you should never see unusual or unexpected output. You should always see exactly three digits, except for inputs under 100.\n\nSome test cases:\n\n```\n0 =\u003e \"0 B\"\n999 =\u003e \"999 B\"\n1000 =\u003e \"1.00 kB\"\n1005 =\u003e \"1.00 kB\"\n1006 =\u003e \"1.01 kB\"\n1014 =\u003e \"1.01 kB\"\n1015 =\u003e \"1.02 kB\"\n9995 =\u003e \"10.0 kB\"\n314000 =\u003e \"314 kB\"\n18400000000000000000 =\u003e \"18.4 EB\"\n```\n\n## Parsing\n\nThe parser understands decimal numbers, decimal SI prefixes, and binary SI prefixes. It is not case-sensitive. A sequence ASCII space (0x20) and tab (0x09) characters may optionally appear between the number and the units. The parser will recognize all positve prefixes which are powers of 1,000, including prefixes that will overflow (yotta and zetta).\n\nSome test cases:\n\n```\n\"0\" =\u003e 0\n\"1\" =\u003e 1\n\"555k\" =\u003e 555000\n\"15 EiB\" =\u003e 17293822569102704640\n\"1.5 mb\" =\u003e 1500000\n\"2gi\" =\u003e 2147483648\n\"0.001 zb\" =\u003e 1000000000000000000\n```\n\n## License\n\nThis library is licensed under the terms of both the MIT license and the Apache 2.0 license. See [LICENSE-MIT.txt](LICENSE-MIT.txt) and [LICENSE-APACHE.txt](LICENSE-APACHE.txt) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdepp%2Fbytesize-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdepp%2Fbytesize-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdepp%2Fbytesize-rs/lists"}