summaryrefslogtreecommitdiff
path: root/crates/tor-netdoc/src/encode.rs
Commit message (Collapse)AuthorAgeFilesLines
* tor-netdoc: Replace trivial string sliceClara Engler2026-06-241-2/+1
|
* tor-netdoc: Use assert_eq_or_diff in three more placesIan Jackson2026-06-111-4/+2
|
* everywhere: Add #[allow(clippy::string_slice)]Clara Engler2026-06-091-0/+1
| | | | | | | | This commit adds #[allow(clippy::string_slice)] to all functions in the code where string slices are used, alongside a TODO comment. We do this add the function header to have it consistent, as things like expression based allow's are still experimental.
* 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.
* Upgrade rand crates to 0.10.Wesley Aptekar-Cassels2026-05-121-2/+2
| | | | | | | | | | | When the circ-padding feature is enabled, we use maybenot, which does not yet support rand 0.10. In the meantime, enabling this feature pulls in rand 0.9. This is not ideal, but should be okay as a temporary situation. This also replaces the use of ReseedingRng (which was removed in 0.10) with the reseeding_rng crate. This is somewhat less performant, but it should be okay.
* tor-netdoc: Move FromStr and Display from NormalItemArgument to implsIan Jackson2026-04-291-1/+1
| | | | | | | | | | | This allows implementing NormalItemArgument for types that can only be parsed, or only displayed - or other combinations. I noticed this restriction while inventing a type I later decided was unnecessary. I still think it's a good change. There is no practical impact elsewhere, since in practice downstream code implements NormalItemArgument rather than relying on it.
* tor-netdoc: Implement encoding traits for Arc<T>Ian Jackson2026-04-211-0/+1
|
* tor-netdoc: encode: Move various ItemArgument impls to impls.rsIan Jackson2026-04-011-63/+0
|
* tor-netdoc: impl encoding traits for rsa::PublicKeyIan Jackson2026-04-011-0/+1
|
* tor-netdoc: Provide ItemEncoder::text_sofar()Ian Jackson2026-04-011-0/+5
|
* tor-netdoc: Provide ItemEncoder::object() taking an ItemObjectEncodableIan Jackson2026-04-011-0/+13
|
* tor-netdoc: encode: re-export netdoc_ordering_check for macrosIan Jackson2026-04-011-0/+1
| | | | Otherwise deriving NetdocEncodable doesn't work outside this crate.
* tor-netdoc: encoder: Rename .object() method to .object_bytesIan Jackson2026-03-311-6/+6
| | | | | | | | | | | With the introduction of the derives for document encoding, we now have a trait ItemObjectEncodable. We will want a method on ItemEncoder that takes an ItemObjectEncodable, and that should be called `object` since it's a better approach than working ad-hoc with tor_bytes::Writeable. (For example, an ItemObjectEncodable knows its own label.) So, rename `object` to `object_bytes`.
* tor-netdoc: encoding: Plan for encoding signed documentsIan Jackson2026-03-191-0/+23
|
* tor-netdoc: Add two TODOs re trait namingIan Jackson2025-12-101-0/+2
|
* tor-netdoc: derive netdoc encoding traitsIan Jackson2025-12-101-0/+3
| | | | | Signature encoding is not yet supported. We need to consider how this will work.
* tor-netdoc: encoding: Provide multiplicity moduleIan Jackson2025-12-101-0/+6
| | | | | | | | This is quite like the one for parse2, but separate for Reasons. Also add a bit of explanation to parse2's multiplicity.rs, about why there are all these different FooSetMethods traits, which the encoder doesn't need.
* tor-netdoc: encoding: Add new traits that we will deriveIan Jackson2025-12-101-0/+99
| | | | And implement them for Void and tuples, as applicable.
* tor-netdoc: Add imports to encode module, for new encode deriveIan Jackson2025-12-101-2/+18
| | | | | Adding these all at the beginning helped me with churn in this branch. The allow(unused) will go away again shortly.
* tor-netdoc: Provide ItemEncoder::finishIan Jackson2025-12-041-0/+5
| | | | | This provides a way to explicitly consume the encoder and finish the item, without use of mem::drop.
* tor-netdoc: Improve and expose args_raw_stringIan Jackson2025-12-041-3/+1
| | | | | | | | The new derive is going to want this. So it would need to be at least `#[doc(hidden)]`. But it makes sense to expose it. But, it had a weird signature. Make its signature like that of `.arg_empty()`. (Note that an ItemEncoder contains just a `&mut NetdocEncoder`.)
* tor-netdoc: Better error from empty argument (fmt)Ian Jackson2025-12-041-1/+4
|
* tor-netdoc: Better error from empty argumentIan Jackson2025-12-041-1/+1
| | | | | talking about the "keyword argument syntax" makes it sound a bit like its' the *keyword* that is wrong.
* tor-netdoc: Throw rather than squirreling error from NormalItemArgumentIan Jackson2025-12-041-3/+1
| | | | | | | | | NormalItemArgument is for types where we use the Display as the netdoc argument formatter. But what if gives the empty string? Previously we would allow `add_arg` to handle the error. That would record it in the NetdocEncoder. That's kind of OK, but it will prevent the caller from aborting early (and from elaborating the error).
* tor-netdoc: Explain some downsides to use of ItemEncoder::argIan Jackson2025-12-041-0/+3
|
* tor-netdoc: Rename ItemArgument method to write_arg_ontoIan Jackson2025-11-261-9/+9
| | | | | | | tor_bytes also has a write_onto method. And types (especially utility types like `Ignored`) might conceivably implement both! No need for semver update since this was pub(crate) in the previous release.
* tor-netdoc: encode: Explain why NetdocEncoder contains a ResultIan Jackson2025-11-191-1/+2
|
* tor-netdoc: impl Default for NetdocEncoderIan Jackson2025-11-181-0/+7
| | | | | clippy points out that if argument-less `new` can exist, so should Default.
* tor-netdoc: Make much more of the encode module contents publicIan Jackson2025-11-181-13/+12
| | | | | My planned new derive for encoding will be pub, but cfg gated, like parse2 is.
* tor-netdoc: Add a note about the nature of NetdocBuilderIan Jackson2025-11-181-1/+13
|
* tor-netdoc: Split off Keyword::to_str into its own traitIan Jackson2025-11-181-2/+2
| | | | | My planned encoding derive macro is not going to use `decl_keyword!` but will need to call `NetdocEncoder::item`.
* tor-netdoc: Rename the `build` module to `encode`Ian Jackson2025-11-101-0/+435
The word "build" so often in Rust means builder pattern. This module contains functions for encoding.