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

Added implementation of timestamp key #431

Merged
merged 2 commits into from
Sep 20, 2021
Merged

Conversation

hashedone
Copy link
Contributor

@hashedone hashedone commented Sep 17, 2021

Closes #419

packages/storage-plus/src/keys.rs Outdated Show resolved Hide resolved
Copy link
Member

@ethanfrey ethanfrey left a comment

Choose a reason for hiding this comment

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

looks good minus the assert

packages/storage-plus/src/keys.rs Outdated Show resolved Hide resolved
}
}

impl From<Timestamp> for TimestampKey {
Copy link
Member

Choose a reason for hiding this comment

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

nice

packages/storage-plus/src/keys.rs Show resolved Hide resolved
@@ -250,7 +250,8 @@ impl<T: Endian> From<T> for IntKey<T> {

impl<T: Endian> From<Vec<u8>> for IntKey<T> {
fn from(wrap: Vec<u8>) -> Self {
// TODO: assert proper length
// TODO: Consider properly handling case, when `wrap` has length not conforming for the
Copy link
Member

Choose a reason for hiding this comment

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

Fair enough. Let's do look at TryFrom at some point...

Copy link
Contributor

Choose a reason for hiding this comment

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

Solution here is in fact not to implement From, and implement TryFrom instead. That's what Rust std does.

@ethanfrey ethanfrey merged commit 120a6e5 into main Sep 20, 2021
@ethanfrey ethanfrey deleted the 419-timestamp-primary-key branch September 20, 2021 08:12
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.

Implement PrimaryKey for Timestamp
4 participants