Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix docs on ToArrayError #169

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tcharding
Copy link
Member

The docs are slightly incorrect. Make them match those on the ToBytesError type.

Noticed while testing the upcoming alpha release.

The docs are slightly incorrect. Make them match those on the
`ToBytesError` type.

Noticed while testing the upcoming alpha release.
@tcharding tcharding added the port-1.0.0-alpha Needs porting to the alpha release branch label Mar 16, 2025
@tcharding tcharding added the trivial Obvious, easy and quick to review (few lines or doc-only...) label Mar 16, 2025
@@ -207,7 +207,7 @@ impl From<InvalidLengthError> for HexToArrayError {
fn from(e: InvalidLengthError) -> Self { Self(e.into()) }
}

/// Hex decoding error while parsing a byte array.
/// Hex decoding error while parsing to an array of bytes.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ToArrayError {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whaat??? Why are we calling these error types To*Error? Why not Parse*Error or Decode*Error?

Oh, I think I know. Wasn't it previously called HexTo*Error? So the intended use is hex::To*Error?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooph, I did not see this discussion until I posted elsewhere and now I don't know where that was. Goodness me. Anyway, I attempted to explain how these error types came to exist someplace - you'll see it in your notifications hopefully.

@@ -207,7 +207,7 @@ impl From<InvalidLengthError> for HexToArrayError {
fn from(e: InvalidLengthError) -> Self { Self(e.into()) }
}

/// Hex decoding error while parsing a byte array.
/// Hex decoding error while parsing to an array of bytes.
Copy link
Collaborator

@Kixunil Kixunil Mar 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the previous wording better so if you want to make them consistent, I'd rather change the other one. After some thinking, I don't like either. I think "decoding into an array of bytes" is better. But also I'm not sure about using the word "parsing" vs "decoding". I think "decoding" fits better in the context of this crate. (Of course, if you have some hex-encoded object like PublicKey then the word "parsing" makes more sense.)

@Kixunil
Copy link
Collaborator

Kixunil commented Mar 17, 2025

On wording. "To decode X <no to/into/from here>" - I believe X refers to the input (hex in this case). However "to parse X" - X refers to the output but the term "parse" is used for objects not encoding transformations. "To decode X from Y" Y is input, X is output.

So we want the word "decode" and we want to be explicit about output type, so we need to say "decode hex into Type"

Also for some reason into feels better than to here but I have no idea why. It's just intuition.

@apoelstra
Copy link
Member

Agreed with your comments in general. I also don't mind renaming the error types since the pain will be fairly limited (only people wrapping the errors will be hit by them). Though for the same reason I really don't care about them.

Also agreed that we should use "decode" and "encode" rather than "parse" and "serialize". Hex to bytes is not transforming the data in any way, just changing the encoding.

But what should we do about this PR? Change it so that it renames the types? Or can we accept the doc changes as is?

@Kixunil
Copy link
Collaborator

Kixunil commented Mar 17, 2025

My suggestion is, to change "parsing to" to "decoding into" at the place this PR modifies and also at the other place that supposedly should be the same to fulfill the goal of the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
port-1.0.0-alpha Needs porting to the alpha release branch trivial Obvious, easy and quick to review (few lines or doc-only...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants