Commit Graph
16 Commits
Author SHA1 Message Date
swaits f3deb17832 style: move clippy allows to specific lines of code
Signed-off-by: Stephen Waits <steve@waits.net>
2023-02-13 11:40:12 -07:00
swaits 2809dbc280 refactor: clean up by using cfg-if where possible
Signed-off-by: Stephen Waits <steve@waits.net>
2023-02-13 10:41:49 -07:00
swaits b70449a9c2 refactor: misc cleanup- move from std::ops to core::ops- remove unnecessary println! calls in testsSigned-off-by: Stephen Waits <steve@waits.net> 2023-02-13 09:52:35 -07:00
swaits f5ddbc0533 refactor: change unwrap()s to expects() and deny in clippy
Signed-off-by: Stephen Waits <steve@waits.net>
2023-02-13 09:30:00 -07:00
swaits 1e1365ee13 refactor: change std::time::Duration to std::core::Duration
One step closer to `no_std`.

Signed-off-by: Stephen Waits <steve@waits.net>
2023-02-13 09:29:12 -07:00
swaits 28097611a7 test: get to 100% coverage, clean up cargo features
- eliminated `f64` feature because Cargo doesn’t understand mutually exclusive features. So, we default to `f64`, and leave the `f32` feature there if people want to change to that.
- integrated tarpaulin for coverage
- added tests to get to 100% coverage
- fixed NetworkCoordinate Div impl safety checks (now acts like Add and Sub)
- update README to explain cargo feature change
- cleanup build script with the new simpler features model

Signed-off-by: Stephen Waits <steve@waits.net>
2023-02-10 12:14:24 -07:00
swaits c192739a14 docs: updates to NetworkCoordinateSigned-off-by: Stephen Waits <steve@waits.net> 2023-02-09 11:17:27 -07:00
swaits da6a70e08d build: enable and fix stricter clippy linting- add clippy to .build.yml to run on sr.ht- add missing docs- use core:: instead of std:: where possible- use hypot() and mul_add() for better numeric stability- make all float tests use asser_approx_eq() and explicitly check for NaN/Inf- add missing semicolons here and there- add #[must_use] to ensure caller uses returned value- add const fn where appropriate- change visibility from pub(crate) to pub (in private modules)Signed-off-by: Stephen Waits <steve@waits.net> 2023-02-09 10:54:42 -07:00
swaits 9d0a318248 feat: f32/f64 cargo features added
Signed-off-by: Stephen Waits <steve@waits.net>
2023-02-08 17:01:19 -07:00
swaits 1bfdce1c21 docs: minor updates re: type aliases, crate to 0.5.1Signed-off-by: Stephen Waits <steve@waits.net> 2023-02-08 15:59:15 -07:00
swaits 02c99ae0de feat: improve ergonomics for serialization format
Goal: To make the serialization format more sensible instead of it being a reflection of our internal (ie private) data model.

- mostly handled with #[serde()] macros (renaming, flattening)
- renamed NetworkCoordinate::position to heightvec which is a better name, even if not seen in the published interface
- changed HeightVector from a tuple struct to a named struct so we can control serde on a field-by-field basis
- updated README, tests, and doc tests to match

Signed-off-by: Stephen Waits <steve@waits.net>
2023-02-08 15:32:27 -07:00
swaits 8f95ed8c9f test: add test for NetworkCoordinate::estimate_rtt
Signed-off-by: Stephen Waits <steve@waits.net>
2023-02-07 21:43:35 -07:00
swaits 26a7b243dc fix: add numeric stability
Made `HeightVector` numerically safe; while `Vector` remains numerically unsafe (i.e. it can divide by 0, NaN, Inf, etc).

When HeightVector runs into a problem, it just re-randomizes itself. Since the algorithm converges relatively quickly, this seems to work fine.

Also fixed a bug so that now height will always start as a positive number (and stay that way, else get re-randomized).

Added safety to `NetworkCoordinate` which now checks that its error didn’t pull a `HeightVector` into a negative height; in which case it also re-randomizes.

Clarified the `random` construction, tweaked the DEFAULT_ERROR constant, and updated tests accordingly.

Signed-off-by: Stephen Waits <steve@waits.net>
2023-02-07 20:25:10 -07:00
swaits 3347e5fe0d docs: clean up export, add module level docs- public NetworkCoordinate so it’s easer to just use vivaldi_nc::NetworkCoordinate- add module level docs and examples in lib.rs- cleanup READMESigned-off-by: Stephen Waits <steve@waits.net> 2023-02-04 10:39:59 -07:00
swaits b3147dfad7 feat: add serde
Adds serialization/deserialization support via serde and serde_with.

Also:

- remove `license-file` in Cargo.toml (superfluous)
- update README with Getting Started section
- add `serde` and `serde_with` dependencies to README
- add tests to `HeightVector`
- tweak assertion in `NetworkCoordinate`
- refactor `Vector` to be a struct witn an `inner` instead of a tuple struct so that we can use `serde_as` (from `serde_with`) to help us derive SerDe implementations for the const generic sized array
- moved trait requirements (which are getting long) into where clauses

Signed-off-by: Stephen Waits <steve@waits.net>
2023-02-04 09:42:46 -07:00
swaits f29deb5335 initial commit
Includes an initial implementation, some tests, and some documentation.

Signed-off-by: Stephen Waits <steve@waits.net>
2023-02-02 21:19:09 -07:00