aboutsummaryrefslogtreecommitdiff
path: root/src/rust/protover/lib.rs
AgeCommit message (Collapse)Author
2019-01-16Bump copyright date to 2019Nick Mathewson
2018-08-16rust: run rustfmtcypherpunks
2018-08-16rust/docs: fix critical typo for missing_docs lintcypherpunks
Fix typo from fe66d06a45a4714141eba992fe87ec3dd5fa1c22. The exclamation point is what lets an attribute apply to an entire crate, without the ! it's practically a placebo. Fix on commits af182d4ab51d6a1a70559bbdcd4ab842aa855684 and b6059297d7cb76f0e00e2098e38d6677d3033340, and note there are still missing docs in both crypto and protover, for now. https://doc.rust-lang.org/reference/attributes.html
2018-06-20Update copyrights to 2018.Nick Mathewson
2018-04-02rust: Add new protover::UnvalidatedProtoEntry type.Isis Lovecruft
This adds a new protover::UnvalidatedProtoEntry type, which is the UnknownProtocol variant of a ProtoEntry, and refactors several functions which should operate on this type into methods. This also fixes what was previously another difference to the C implementation: if you asked the C version of protovet_compute_vote() to compute a single vote containing "Fribble=", it would return NULL. However, the Rust version would return "Fribble=" since it didn't check if the versions were empty before constructing the string of differences. ("Fribble=" is technically a valid protover string.) This is now fixed, and the Rust version in that case will, analogous to (although safer than) C returning a NULL, return None. * REMOVE internal `contains_only_supported_protocols()` function. * REMOVE `all_supported()` function and refactor it into `UnvalidatedProtoEntry::all_supported()`. * REMOVE `parse_protocols_from_string_with_no_validation()` and refactor it into the more rusty implementation of `impl FromStr for UnvalidatedProtoEntry`. * REMOVE `protover_string_supports_protocol()` and refactor it into `UnvalidatedProtoEntry::supports_protocol()`. * REMOVE `protover_string_supports_protocol_or_later()` and refactor it into `UnvalidatedProtoEntry::supports_protocol_or_later()`. * FIXES part of #24031: https://bugs.torproject.org/24031 rust: Fix another C/Rust different in compute_vote(). This fixes the unittest from the prior commit by checking if the versions are empty before adding a protocol to a vote.
2018-04-02rust: Implement more memory-efficient protover datatype.Isis Lovecruft
* ADD new protover::protoset module. * ADD new protover::protoset::ProtoSet class for holding protover versions. * REMOVE protover::Versions type implementation and its method `from_version_string()`, and instead implement this behaviour in a more rust-like manner as `impl FromStr for ProtoSet`. * MOVE the `find_range()` utility function from protover::protover to protover::protoset since it's only used internally in the implementation of ProtoSet. * REMOVE the `contract_protocol_list()` function from protover::protover and instead refactor it (reusing nearly the entire thing, with minor superficial, i.e. non-behavioural, changes) into a more rusty `impl ToString for ProtoSet`. * REMOVE the `expand_version_range()` function from protover::protover and instead refactor it into a more rusty implementation of `impl Into<Vec<Version>> for ProtoSet` using the new error types in protover::errors. * FIXES part of #24031: https://bugs.torproject.org/24031.
2018-04-02rust: Implement error types for Rust protover implementation.Isis Lovecruft
This will allow us to do actual error handling intra-crate in a more rusty manner, e.g. propogating errors in match statements, conversion between error types, logging messages, etc. * FIXES part of #24031: https://bugs.torproject.org/24031.
2018-03-19Merge remote-tracking branch 'isis/bug23881_r1'Nick Mathewson
2018-02-10rust: Use tor_util::strings utils for protover_get_supported_protocols.Isis Lovecruft
2018-02-07protover: Fix memleak in Rust impl of protover_compute_for_old_tor.Isis Lovecruft
* FIXES #25127: https://bugs.torproject.org/25127 * ADDS a new module to the Rust tor_util crate for small utilities for working with static strings between languages. * CHANGES the return type of protover_compute_for_old_tor to point to immutable data. * CHANGES the code from the previous commit to use the new static string utilities.
2017-12-21move macro body to inline rust functionChelsea Holland Komlo
2017-12-21add minimal rust module for logging to tor's loggerChelsea Holland Komlo
Allows an optional no-op for testing purposes
2017-10-27remove experimental rust featuresChelsea Holland Komlo
allow unsafe on function that calls C
2017-10-27use tor allocator for string allocation in rustChelsea Holland Komlo
2017-10-27rust implementation of protoverChelsea Holland Komlo