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

Upgrade the bytes package. #44

Merged
merged 1 commit into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 12 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"
[dependencies]
async-std = {version = "1.12", features = ["attributes"]}
async-trait = "0.1.80"
bytes = "0.6"
bytes = "1.6"
chrono = "0.4"
futures = "0.3"
im = "15"
Expand Down
8 changes: 2 additions & 6 deletions src/keyvalue/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@ extern crate bytes;
extern crate im;

use std::collections::VecDeque;

use bytes::Bytes;
use im::HashMap;
use prost::Message;

use keyvalue_proto::{Entry, Operation, Snapshot};

use crate::keyvalue::keyvalue_proto;
use crate::keyvalue::keyvalue_proto::operation::Op::Set;
use crate::raft::{StateMachine, StateMachineResult};

use self::bytes::Buf;

#[derive(Debug, Clone)]
pub struct StoreError {
_message: String,
Expand Down Expand Up @@ -159,7 +155,7 @@ impl Store for MapStore {

impl StateMachine for MapStore {
fn apply(&mut self, payload: &Bytes) -> StateMachineResult {
let parsed = Operation::decode(payload.bytes());
let parsed = Operation::decode(payload.to_owned());
if parsed.is_err() {
return Err(format!(
"Failed to parse bytes: {:?}",
Expand Down Expand Up @@ -195,7 +191,7 @@ impl StateMachine for MapStore {
// Discards all versions present in the current store instance, replacing
// them with the supplied version.
fn load_snapshot(&mut self, snapshot: &Bytes) -> StateMachineResult {
let parsed = Snapshot::decode(snapshot.bytes());
let parsed = Snapshot::decode(snapshot.to_owned());
if parsed.is_err() {
return Err(format!(
"Failed to parse snapshot: {:?}",
Expand Down
Loading