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 Compression to_string and into string impls #175

Merged
merged 3 commits into from
Feb 13, 2024

Conversation

conorbros
Copy link
Contributor

No description provided.

Copy link
Owner

@krojew krojew left a comment

Choose a reason for hiding this comment

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

Why is this needed?

cassandra-protocol/src/compression.rs Show resolved Hide resolved
match self {
Compression::Lz4 => write!(fmt, "lz4"),
Compression::Snappy => write!(fmt, "snappy"),
Compression::None => write!(fmt, "none"),
Copy link
Owner

Choose a reason for hiding this comment

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

This is inconsistent with the implementation above.

@conorbros
Copy link
Contributor Author

I proposed this change so that the to_string function for the Compression enum formats it correctly according to the protocol spec. It should be either all caps or lowercase. The default impl will format it as the enum name e.g. "Snappy", when it should be "snappy" or "SNAPPY".

@krojew
Copy link
Owner

krojew commented Feb 5, 2024

In Rust typically string representations of enums reflect the names itself. I think it would be better to explicitly add to_protocol_string()/from_protocol_string() or similar.

@@ -64,7 +63,7 @@ impl Clone for CompressionError {
}

/// Enum which represents a type of compression. Only non-startup frame's body can be compressed.
#[derive(Debug, PartialEq, Clone, Copy, Eq, Ord, PartialOrd, Hash, Display)]
#[derive(Debug, PartialEq, Clone, Copy, Eq, Ord, PartialOrd, Hash)]
Copy link
Owner

Choose a reason for hiding this comment

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

You forgot to put back Display.

@krojew krojew merged commit a47ddd5 into krojew:master Feb 13, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants