aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-bytes/src
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'take_until_with_limit' into 'main'Nick Mathewson13 days2-10/+90
|\ | | | | | | | | Add take_until_with_limit methods for better developer experience, modified error handling, changed take_until to use take_until_with_limit and added tests. See merge request tpo/core/arti!4082
| * Add take_until_with_limit methods for better developer experience,pryty262026-07-022-10/+90
| | | | | | | | | | These methods provide modified error handling, changed take_until to use take_until_with_limit and added tests.
* | add_warning: add reference to arti#2556Jim Newsome2026-07-151-1/+1
| |
* | Removed unnecessary lintpryty262026-07-152-2/+1
|/ | | | Removed unnecessary lint
* maint: Run maint/add_warning to deny string slicesClara Engler2026-06-092-0/+3
| | | | | | | | | | | | This commit executes maint/add_warning with the just added change to deny string slices except in tests. I recommend auditing this by checking out the previous commit followed by running the script yourself and then verifying that the diff is identical to this commit. This commit makes cargo clippy fail. We will add exceptions in the next commit.
* Allow clippy::collapsible_if to triggerGabriela Moldovan2026-02-161-0/+1
| | | | | | | | | `clippy::collapsible_if` started triggering after bumping the MSRV to 1.88. Since this triggers from a lot of places, and since there even are a couple of instances where we explicitly allow `clippy::collapsible_ifs`, I've opened #2342 for deciding what to do about it.
* maint/add_warning: Run script to add new warningGabriela Moldovan2026-01-271-0/+1
| | | | This adds the lint to all our crates.
* Fix name of clippy lint to unchecked_time_subtraction (2)Ian Jackson2025-11-062-3/+3
| | | | Run maint/add_warning
* Remove "doc_auto_cfg" incantation from all crates.Nick Mathewson2025-09-291-1/+1
| | | | This feature has been removed from nightly, in favor of doc_cfg.
* tor-bytes: simplify commentTobias Stoeckmann2025-09-031-3/+3
| | | | | | | | | | The first sentence states that we have to reallocate and the second one states that we "might" have to do so. Skip the redundancy. While at it, use the term "to zeroize" instead of introducing "to zero", since the former is already used in a subsequent sentence.
* Switch Cargo.toml files to edition 2024.Nick Mathewson2025-08-072-3/+3
| | | | | | | | | | | | | | First, run ``` git grep -l "^edition =" | xargs perl -i -pe 's/^edition *=.*/edition = "2024"/;' ``` Second, manually verify that all Cargo.toml files have changed, and nothing else has changed. Third, run cargo fmt again.
* Fix errors from rustdoc nightly.Nick Mathewson2025-08-051-1/+1
|
* Temporarily suppress mismatched_lifetime_syntaxes.Gabriela Moldovan2025-07-071-0/+1
| | | | See #2060.
* fix: fix typosDimitris Apostolou2025-01-301-1/+1
|
* clippy: deny `mod_module_files`Steven Engler2025-01-061-0/+1
| | | | | | Denies 'mod.rs' files for consistency. https://rust-lang.github.io/rust-clippy/master/index.html#mod_module_files
* add_warnings, *: Allow clippy::needless_lifetimesNick Mathewson2024-12-031-0/+1
| | | | | | | | In 1.83, this warning triggers on many of our crates. We're thinking of fixing them all, but for now, we're going to disable the warning. This is part of #1765.
* tor-bytes: Make "tor-llcrypto" dependency optional.Nick Mathewson2024-10-091-0/+10
| | | | | | This is part of an effort to make arti-rpc-client-core (and future similar tools) able to use our very-low-level crates without depending on things they don't need.
* tor-bytes: Restore the message for Error::TruncatedIan Jackson2024-10-011-1/+1
| | | | | This variant is deprecated but it still ought to have a message so long as it exists.
* tor-proto: Use Reader::take_all_but().Nick Mathewson2024-09-161-13/+14
|
* tor-bytes: Add a new take_all_but method.Nick Mathewson2024-09-161-0/+73
|
* tor-bytes: Fix Truncated refs in various docs.Ian Jackson2024-09-121-4/+5
| | | | | | Use "throws" terminology to avoid having to clutter the description with Err(). Many of these doc comments contain otiose text such as "returns Ok(()) on success" but let's not deal with that now.
* tor-bytes: Rename OnIncomplete to Completeness (fmt)Ian Jackson2024-09-121-1/+1
|
* tor-bytes: Rename OnIncomplete to CompletenessIan Jackson2024-09-121-11/+20
| | | | | | | | And rename its variants and update the docs to contemplate wider use, as suggested in #1620. As discussed here https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2407#note_3075658
* tor_bytes: Clarify a method docIan Jackson2024-09-121-2/+3
| | | | | Apropos https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2407#note_3075638
* tor_bytes: Rename new_truncated_for_test to new_incomplete_for_testIan Jackson2024-09-122-14/+14
| | | | No semver implications since this wasn't in the last release.
* tor-bytes: Add test case for from_possibly_incomplete_sliceIan Jackson2024-09-121-0/+8
| | | | | Prompted by https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2407#note_3075486
* tor-bytes: Add note about other kinds of invalid messageIan Jackson2024-09-111-0/+11
| | | | | Prompted by https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2407#note_3075485
* tor-bytes: Add imprecations about Incomplete and MissingDataIan Jackson2024-09-111-0/+17
| | | | | Prompted by https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2407#note_3075483
* tor-bytes: Fix a doc comment about error reportingIan Jackson2024-09-111-1/+1
| | | | This was a leftover from before I invented Error::MissingData.
* tor-bytes: Do many missed renames of Truncated to IncompleteIan Jackson2024-09-113-9/+9
|
* tor-bytes: Add warning about sub-readers (adjust to new name)Ian Jackson2024-09-111-1/+1
| | | | | Fix semantic conflict of the suggested edit with the rename later in the branch.
* tor-bytes: Add warning about sub-readersIan Jackson2024-09-111-0/+9
| | | | | Suggestion from here https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2407#note_3075481
* tor-bytes: Rename Truncated to Incomplete, and restore old Truncated as ↵Ian Jackson2024-09-112-5/+10
| | | | | | | | | deprecated Incomplete is a better name. This lets us use Truncated for the old, deprecated, conflation of "Incomplete" with what is now "MissingData".
* tor-bytes: Only report Truncated for errors at the outer level (fmt)Ian Jackson2024-09-111-2/+10
|
* tor-bytes: Only report Truncated for errors at the outer levelIan Jackson2024-09-112-12/+30
| | | | | | | | | | | This is item 1 from https://gitlab.torproject.org/tpo/core/arti/-/issues/1614#note_3074562 and the alternative to item 2 presented in the 2nd half of https://gitlab.torproject.org/tpo/core/arti/-/issues/1614#note_3074648 (Item 3 was done earlier, but now we change the behaviour.) Fixes #1614.
* tor-bytes: Error: provide and call Error::incomplete_error (tidy)Ian Jackson2024-09-111-4/+1
| | | | | Tidy up an error message. Now this can be on one line with variable name interpolation.
* tor-bytes: Error: provide and call Error::incomplete_error (fmt)Ian Jackson2024-09-112-8/+11
|
* tor-bytes: Error: provide and call Error::incomplete_errorIan Jackson2024-09-112-9/+21
| | | | | | | | | | | | | | | | | | | We introduce the new constructor and call it at the error generation sites. But there is still not yet any functional change. Change the type of Truncated's field to be Sensitive. The original reason for not doing this no longer applies, since we don't generally want to open-code construction of this variant. Conveniently, changing the type means we get to find all the sites where one *is* constructed and adjust them. In reader.rs and tor-proto we can just call incomplete_error. In tor-cell, there's a call site where we previously provided an underestimate, and where the Reader isn't available. We adjust that ad-hoc but this is fine because the error variant will change. (relaycell is using a Reader from from_slice.)
* tor-bytes: Add a Reader constructor for tor-socksproto's use caseIan Jackson2024-09-111-3/+23
| | | | | | | Here we add the constructor, and document it, and change the call sites. No functional change yet.
* tor-bytes: Add a test case with missing inner dataIan Jackson2024-09-111-0/+9
| | | | Some tests in other crates test this, but none in tor-bytes!
* tor-bytes: Add a Reader constructor for use in testsIan Jackson2024-09-112-16/+28
| | | | | | | | | | | | We could call from_possibly_incomplete_slice in these, but that's confusing and distracting. Here we add this constructor, and document it (in terms of the constructor to come), and change the call sites. No functional change. Doing this now will prevent unwanted changes to test behaviours when we change the behaviour of Readers made by Reader::from_slice.
* tor-bytes: derive impl PartialEq for ErrorIan Jackson2024-09-111-17/+27
| | | | | | | I just perpetrated a bug by adding a variant to this which ended up not PartialEq to itself. This open-coded match is a footgun. No functional change.
* Change tor_bytes::Readable name to `b` in many placesIan Jackson2024-09-112-114/+114
| | | | | | | | | | | | | | | The codebase uses `r` sometimes and `b` at other times. Making this consistent makes widespread changes easier, and is clearer for humans. I think `b` is better than `r` because `r` might be "return". It is indeed used that way in a couple of places in reader.rs, even. I haven't changed *everywhere*, just Readable impls (where `r` is particularly likely to be "return value") and occurrences in tor-bytes. No functional change.
* tor-bytes: Error::Truncated: mark the deficit as Sensitive (fmt)Ian Jackson2024-09-101-2/+4
|
* tor-bytes: Error::Truncated: mark the deficit as SensitiveIan Jackson2024-09-101-1/+6
| | | | | Suggested in https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2390#note_3072975
* tor-bytes: Add a deficit field to Error::Truncated (fmt)Ian Jackson2024-09-101-1/+3
|
* tor-bytes: Add a deficit field to Error::TruncatedIan Jackson2024-09-102-8/+14
| | | | This will allow us to fix #1592, but it doesn't do so yet.
* Introduce and use tor_bytes::Error::new_truncated_for_testIan Jackson2024-09-102-11/+26
| | | | | | | | This is going to want to do something more complicated (as described in the docs). In this commit we change all the tests that are expecting Truncated errors. That reduces noise in the next commit.
* tor-bytes: Document Readable::take_from correctness propertiesIan Jackson2024-09-101-0/+29
| | | | | | This refers to the `deficit` field in Error::Truncated, which is going to appear in a later commit. It seems kinder to my reviewer to add this doc now early in the branch.
* tor-bytes: advance: Call peek for the error checkIan Jackson2024-09-101-3/+1
| | | | | This removes one construction site of Error::Truncated. We are about to make constructing one of those more fiddly.