Skip to content

Commit

Permalink
Upgrade the bytes package.
Browse files Browse the repository at this point in the history
  • Loading branch information
dinowernli committed Apr 20, 2024
1 parent 39abfe7 commit dd8dc22
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 25 deletions.
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

0 comments on commit dd8dc22

Please sign in to comment.