Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/x52dev/double-int
The double-int format represents an integer that can be stored in an IEEE 754 double-precision number without loss of precision
https://github.com/x52dev/double-int
openapi serde
Last synced: 13 days ago
JSON representation
The double-int format represents an integer that can be stored in an IEEE 754 double-precision number without loss of precision
- Host: GitHub
- URL: https://github.com/x52dev/double-int
- Owner: x52dev
- License: apache-2.0
- Created: 2024-01-16T15:16:04.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-12-09T17:50:00.000Z (19 days ago)
- Last Synced: 2024-12-09T18:40:46.061Z (19 days ago)
- Topics: openapi, serde
- Language: Rust
- Homepage:
- Size: 180 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# `double-int`
[![crates.io](https://img.shields.io/crates/v/double-int?label=latest)](https://crates.io/crates/double-int)
[![Documentation](https://docs.rs/double-int/badge.svg?version=0.1.3)](https://docs.rs/double-int/0.1.3)
[![dependency status](https://deps.rs/crate/double-int/0.1.3/status.svg)](https://deps.rs/crate/double-int/0.1.3)
![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/double-int.svg)
[![CI](https://github.com/x52dev/double-int/actions/workflows/ci.yml/badge.svg)](https://github.com/x52dev/double-int/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/x52dev/double-int/branch/main/graph/badge.svg)](https://codecov.io/gh/x52dev/double-int)
![Version](https://img.shields.io/badge/rustc-1.56+-ab6000.svg)
[![Download](https://img.shields.io/crates/d/double-int.svg)](https://crates.io/crates/double-int)The double-int format represents an integer that can be stored in an IEEE 754 double-precision number without loss of precision.
This crate has been designed for use with OpenAPI tooling that wish to support integer-based `format: double-int` fields. [See docs in the OpenAPI format registry.][reg_double_int]
## Examples
```rust
#[derive(Debug, serde::Deserialize)]
struct Config {
count: DoubleInt,
}let config = toml::from_str::(r#"
count = 42
"#).unwrap();
assert_eq!(config.count, 42);let config = toml::from_str::(r#"
count = -42
"#).unwrap();
assert_eq!(config.count, -42);// count is outside the bounds of a double-int (> 2^53 in this case)
// (this would usually be accepted by an i64)
let config = toml::from_str::(r#"
count = 36028797018963968
"#).unwrap_err();
```[reg_double_int]: https://spec.openapis.org/registry/format/double-int