aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-netdoc/src/parse/parser.rs
Commit message (Collapse)AuthorAgeFilesLines
* maint: Run maint/add_warning to deny string slicesClara Engler2026-06-091-0/+1
| | | | | | | | | | | | 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.
* Fix name of clippy lint to unchecked_time_subtraction (2)Ian Jackson2025-11-061-1/+1
| | | | Run maint/add_warning
* tor-netdoc: Abolish ParseRouterStatus and make several things not pubIan Jackson2025-08-261-1/+1
| | | | | | | The methods in ParseRouterStatus can now be inherent. This starts a cascade of unused stuff, and stuff which doesn't need to be pub any more.
* tor-netdoc: Removed dependency on `once_cell`hashcatHitman2025-06-141-2/+2
| | | | | | - Replaced `once_cell::sync::Lazy` with `std::sync::LazyLock`. Signed-off-by: hashcatHitman <[email protected]>
* netdoc: Make some parsing init functions fallible.Nick Mathewson2025-03-171-2/+2
| | | | | | | I'm about to make our parsers reject some strings at construction time, so it makes sense to have these functions become fallible. This is a breaking change.
* Run maint/add_warning.Nick Mathewson2024-03-131-0/+1
|
* clippy: Replace many calls to .get(0) with .first()Ian Jackson2024-01-021-1/+1
| | | | | FTR I don't think agree with clippy on this question, but then I often don't.
* Run maint/add_warning to add lint block everywhereIan Jackson2023-08-231-0/+1
|
* Run maint/add_warning to actually apply new lint allowsIan Jackson2023-07-101-0/+1
|
* netdoc: Rename parse_error_kind() to netdoc_error_kind().Gabriela Moldovan2023-05-111-2/+2
| | | | | | | `ParseErrorKind` was renamed to `NetdocErrorKind`, so we need to rename this acccessor too. Signed-off-by: Gabriela Moldovan <[email protected]>
* netdoc: Rename `ParseError{Kind, Source}` to `NetdocError{Kind, Source}`.Gabriela Moldovan2023-05-101-2/+2
| | | | | | | | | | | `ParseErrorSource` was originally meant to represent a parsing error, this enum has since gained some variants that aren't really parsing related (`Signature`, `CertSignature`, `UntimelyDescriptor`). Since this error type is now used for general-purpose netdoc errors, let's rename `ParseError{Kind, Source}` to `NetdocError{Kind, Source}`. Signed-off-by: Gabriela Moldovan <[email protected]>
* tor-netdoc: Remove many needless calls to .iter() and .into_iter()Ian Jackson2023-02-151-4/+4
|
* tor-netdoc: Have sectionrules.parse take I, not &mut IIan Jackson2023-02-151-2/+2
| | | | | | There's a blanket impl of Itertor for &mut impl Iterator, so this isn't necessary, and it prevents us passing iterators by value producing syntactic vinegar.
* netdoc: Require that unrecognized tokens be handled explicitly.Nick Mathewson2023-02-031-5/+29
| | | | | | | | | | | | | | | | | | | | | | | | Now we require that, for all `SectionRules`, either the caller say how to handle unrecognized tokens (using `.add(UNRECOGNIZED...)`), or that they explicitly reject unrecognized tokens (using `reject_unrecognized`()`.) This solution uses an assert!() rather than an Error to indicate failure. I say that's fine, since 1. This is a crate-internal API. 2. We never dynamically construct SectionRules according to different behavior: they are always prefabricated in a fixed code block. Thus, if we test a parser at all, we will make sure that its SectionRules are well-formed. I considered and explicitly rejected a solution where the builder had to be finalized with separate methods `build_strict()` or `build_tolerant()`: It's too easy IMO for the caller to forget what these call means. Prevents further recurrences of #752. Closes #752.
* netdoc: Switch SectionRules building to use a Buidler pattern.Nick Mathewson2023-02-031-15/+29
| | | | No new behavior yet.
* Allow clippy::unchecked_duration_subtraction in testsNick Mathewson2023-01-271-0/+1
| | | | | This panics on error, and we're fine with a panic on misbehavior in tests.
* Elide a bunch of lifetimes.Nick Mathewson2023-01-271-2/+2
| | | | | Clippy now warns about these; I'm not sure how these warnings snuck up on us.
* test lint blocks: Add many many automaticallyIan Jackson2022-12-121-0/+8
| | | | | This is precisely the result of running the rune in maint/adhoc-add-lint-blocks.
* Fix a bunch of "needless borrow" warnings on nightlyNick Mathewson2022-11-181-1/+1
| | | | | It looks like, despite a few false starts, they've got this warning right; there weren't any false positives.
* Replace `Option<Pos>` with `Pos` in `ParseError`.Nick Mathewson2022-11-151-1/+3
| | | | | | | | | | | | | | | We already have `Pos::Unknown` for an error at an unknown location and `Pos::None` for an error where no location is sensible. There's no reason to have an additional `Option` here. Additionally, the use of `Option` gave us a bug where our old `ParseError::at_pos()` method didn't actually set the position unless the position was already set. That's not what we want! Fixes #640. Finally, we have to fix a test that was a bit broken because it was working around #640.
* Netdoc: test enforcement for items that mustn't take objects.Nick Mathewson2022-06-071-0/+6
| | | | Found via coverage.
* netdoc: Test more accessors for tokenized documents.Nick Mathewson2022-06-071-0/+15
|
* tor-netdoc: Actually, make TokVal be a VecIan Jackson2022-03-111-46/+20
| | | | | This enum was otiose: its set of valid values is precisely those of a Vec. (Indeed what would TokVal::Multi(vec![]) have meant?)
* Remove a pointless sliceIan Jackson2022-03-111-10/+7
| | | | std::slice::from_ref exists. Spotted while reviewing !400
* Refactor tor_netdoc::ErrorNick Mathewson2022-02-141-10/+23
| | | | | | | | | | | | | | | This error type doesn't impement HasKind, since the kind will depend on context. However, the existing implementation was pretty messy and inconsistent: Some errors had positions, some didn't. Some took messages as str, some as String. Some had internal errors that were somewhat orthogonal to their actual types. This commit refactors tor_netdoc::Error to use a ParseErrorKind, and adds a set of convenience functions to add positions and messages to the errors that need them.
* add semicolons if nothing returnedDaniel Eades2021-11-251-1/+1
|
* fix/silence clippy lints in test modulesDaniel Eades2021-09-081-8/+9
|
* Move all crates into a `crates` subdirectory.Nick Mathewson2021-08-271-0/+412
This will cause some pain for now, but now is really the best time to do this kind of thing.