Repository navigation
Library API: portable core crate with CLI and WASM adapters - #18
Merged
Merged
Conversation
Cargo workspace:
- eigentrust (root): the library, rlib, builds on every target, no wasm gating
- eigentrust-cli (cli/): the `eigentrust` binary, uses only the public API
- eigentrust-wasm (wasm/): JS bindings, the only cdylib, publish = false
Public API, all re-exported from lib.rs, every module private:
- eigentrust(local_trust, pre_trust) and eigentrust_with_options(.., &options)
- TrustEdge { from, to, weight }, PreTrust { peer, weight }, From tuple impls
- EigenTrustOptions: alpha, epsilon, max_iterations; private fields, builder,
validated before any work
- TrustScores: scores, get, ranking, iterations, residual
- EigenTrustError (#[non_exhaustive]) and Input; no String errors
- csv feature: csv::Network::from_csv with its own Error / ErrorKind
- parallel feature: rayon; default features: none
Behavior and numbers are unchanged: CLI output is byte-identical to the
previous version on 10 reference inputs (up to 5M lines), WASM output is
byte-identical, CLI is ~15% faster, WASM the same.
- crate docs with input rules, convergence and examples; missing_docs on
- examples/basic.rs, examples/csv.rs
- tests/api.rs and tests/csv.rs use the crate like an external consumer
- README Rust example runs as a doc test
- crates.io metadata, include list, docs.rs config; Cargo.lock committed
- removed the unused sparse helpers (CSC, merge, sorting utils) and the
unwired distrust functions; their history stays in git
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Turns the project into a proper Rust library, with the CLI and the WebAssembly bindings as thin adapters over it.
Layout
A Cargo workspace, so the dependency direction is enforced by crate boundaries:
eigentrustsrc/rlib, builds on every target, no wasm gatingeigentrust-clicli/eigentrustbinary; uses only the public APIeigentrust-wasmwasm/cdylib,publish = falsePublic API
Everything is re-exported from
lib.rs, and all modules are private.EigenTrustOptions: alpha, epsilon, max_iterations. Private fields with a builder, validated before any work.EigenTrustErroris#[non_exhaustive], covering invalid options, non-finite, negative or overflowing weights, invalid peers, an empty network and non-convergence.csv:csv::Network::from_csv, with its own error type (line numbers and kinds).parallel: rayon. There are no default features.Verification
mainon 10 reference inputs (up to 5M lines), and the CLI is about 15% faster.tests/api.rs,tests/csv.rs), and doc tests including the README example.-D warningsas docs.rs does.cargo macheteis clean.cargo package -p eigentrust -p eigentrust-clibuilds from the tarballs. The library package is 26 KB of sources, tests, examples, test data and licenses.cargo-semver-checksruns against the base branch. It's informational until the first crates.io release, and I checked that it catches a removed method.Removed