From 93a7b14335b5d2a024ccafbd1634ae8bf6f9e95f Mon Sep 17 00:00:00 2001 From: Kacy Fortner Date: Sat, 14 Feb 2026 17:52:23 -0500 Subject: [PATCH] cargo fmt: fix formatting drift from merged refactoring PRs --- crates/ember-core/src/keyspace.rs | 24 +++- crates/ember-persistence/src/aof.rs | 6 +- crates/ember-server/src/connection.rs | 13 +- crates/ember-server/src/grpc.rs | 164 +++++++------------------- 4 files changed, 65 insertions(+), 142 deletions(-) diff --git a/crates/ember-core/src/keyspace.rs b/crates/ember-core/src/keyspace.rs index 88aa86a9..7a0691c4 100644 --- a/crates/ember-core/src/keyspace.rs +++ b/crates/ember-core/src/keyspace.rs @@ -386,10 +386,16 @@ impl Keyspace { /// Measures entry size before and after a mutation, adjusting the /// memory tracker for the difference. Touches the entry afterwards. fn track_size(&mut self, key: &str, f: impl FnOnce(&mut Entry) -> T) -> T { - let entry = self.entries.get_mut(key).expect("caller verified key exists"); + let entry = self + .entries + .get_mut(key) + .expect("caller verified key exists"); let old_size = memory::entry_size(key, &entry.value); let result = f(entry); - let entry = self.entries.get(key).expect("mutation should not remove key"); + let entry = self + .entries + .get(key) + .expect("mutation should not remove key"); let new_size = memory::entry_size(key, &entry.value); self.memory.adjust(old_size, new_size); result @@ -1128,7 +1134,12 @@ impl Keyspace { .iter() .map(|v| memory::VECDEQUE_ELEMENT_OVERHEAD + v.len()) .sum(); - self.reserve_memory(is_new, key, memory::VECDEQUE_BASE_OVERHEAD, element_increase)?; + self.reserve_memory( + is_new, + key, + memory::VECDEQUE_BASE_OVERHEAD, + element_increase, + )?; if is_new { self.insert_empty(key, Value::List(VecDeque::new())); @@ -1201,8 +1212,7 @@ impl Keyspace { ) -> Result { self.remove_if_expired(key); - let is_new = - self.ensure_collection_type(key, |v| matches!(v, Value::SortedSet(_)))?; + let is_new = self.ensure_collection_type(key, |v| matches!(v, Value::SortedSet(_)))?; // worst-case estimate: assume all members are new let member_increase: usize = members @@ -1260,7 +1270,9 @@ impl Keyspace { return Ok(vec![]); } - let Some(entry) = self.entries.get(key) else { return Ok(vec![]) }; + let Some(entry) = self.entries.get(key) else { + return Ok(vec![]); + }; if !matches!(entry.value, Value::SortedSet(_)) { return Err(WrongType); } diff --git a/crates/ember-persistence/src/aof.rs b/crates/ember-persistence/src/aof.rs index 99dc0698..9c67d23a 100644 --- a/crates/ember-persistence/src/aof.rs +++ b/crates/ember-persistence/src/aof.rs @@ -360,15 +360,13 @@ impl AofRecord { format::write_bytes(&mut buf, key.as_bytes())?; format::write_i64(&mut buf, *milliseconds as i64)?; } - AofRecord::IncrBy { key, delta } - | AofRecord::DecrBy { key, delta } => { + AofRecord::IncrBy { key, delta } | AofRecord::DecrBy { key, delta } => { format::write_bytes(&mut buf, key.as_bytes())?; format::write_i64(&mut buf, *delta)?; } // key + byte list - AofRecord::LPush { key, values } - | AofRecord::RPush { key, values } => { + AofRecord::LPush { key, values } | AofRecord::RPush { key, values } => { format::write_bytes(&mut buf, key.as_bytes())?; format::write_len(&mut buf, values.len())?; for v in values { diff --git a/crates/ember-server/src/connection.rs b/crates/ember-server/src/connection.rs index 11996b56..756f9640 100644 --- a/crates/ember-server/src/connection.rs +++ b/crates/ember-server/src/connection.rs @@ -1249,9 +1249,7 @@ async fn resolve_response( fn resolve_shard_response(resp: ShardResponse, tag: ResponseTag) -> Frame { match tag { // Value(Some(String)) → Bulk, Value(None) → Null - ResponseTag::Get - | ResponseTag::PopResult - | ResponseTag::HGetResult => match resp { + ResponseTag::Get | ResponseTag::PopResult | ResponseTag::HGetResult => match resp { ShardResponse::Value(Some(Value::String(data))) => Frame::Bulk(data), ShardResponse::Value(None) => Frame::Null, ShardResponse::WrongType => wrongtype_error(), @@ -1273,8 +1271,7 @@ fn resolve_shard_response(resp: ShardResponse, tag: ResponseTag) -> Frame { }, // Bool → Integer(0/1), with WrongType - ResponseTag::HExistsResult - | ResponseTag::SIsMemberResult => match resp { + ResponseTag::HExistsResult | ResponseTag::SIsMemberResult => match resp { ShardResponse::Bool(b) => Frame::Integer(i64::from(b)), ShardResponse::WrongType => wrongtype_error(), other => Frame::Error(format!("ERR unexpected shard response: {other:?}")), @@ -1310,8 +1307,7 @@ fn resolve_shard_response(resp: ShardResponse, tag: ResponseTag) -> Frame { }, // Len → Integer, with WrongType + OOM - ResponseTag::LenResultOom - | ResponseTag::HSetResult => match resp { + ResponseTag::LenResultOom | ResponseTag::HSetResult => match resp { ShardResponse::Len(n) => Frame::Integer(n as i64), ShardResponse::WrongType => wrongtype_error(), ShardResponse::OutOfMemory => oom_error(), @@ -1327,8 +1323,7 @@ fn resolve_shard_response(resp: ShardResponse, tag: ResponseTag) -> Frame { }, // Array of Bytes → Array of Bulk - ResponseTag::ArrayResult - | ResponseTag::HValsResult => match resp { + ResponseTag::ArrayResult | ResponseTag::HValsResult => match resp { ShardResponse::Array(items) => { Frame::Array(items.into_iter().map(Frame::Bulk).collect()) } diff --git a/crates/ember-server/src/grpc.rs b/crates/ember-server/src/grpc.rs index 6b07a022..6f36ee74 100644 --- a/crates/ember-server/src/grpc.rs +++ b/crates/ember-server/src/grpc.rs @@ -165,9 +165,7 @@ impl EmberCache for EmberService { value: Some(value_to_bytes(v)), })), ShardResponse::Value(None) => Ok(Response::new(GetResponse { value: None })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -196,9 +194,7 @@ impl EmberCache for EmberService { ShardResponse::Ok => Ok(Response::new(SetResponse { ok: true })), ShardResponse::Value(None) => Ok(Response::new(SetResponse { ok: false })), ShardResponse::OutOfMemory => Err(Status::resource_exhausted("OOM")), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -309,9 +305,7 @@ impl EmberCache for EmberService { match resp { ShardResponse::Integer(v) => Ok(Response::new(IntResponse { value: v })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -334,9 +328,7 @@ impl EmberCache for EmberService { match resp { ShardResponse::Integer(v) => Ok(Response::new(IntResponse { value: v })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -359,9 +351,7 @@ impl EmberCache for EmberService { match resp { ShardResponse::Integer(v) => Ok(Response::new(IntResponse { value: v })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -384,9 +374,7 @@ impl EmberCache for EmberService { match resp { ShardResponse::BulkString(s) => Ok(Response::new(FloatResponse { value: s })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -409,9 +397,7 @@ impl EmberCache for EmberService { match resp { ShardResponse::Len(n) => Ok(Response::new(IntResponse { value: n as i64 })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -428,9 +414,7 @@ impl EmberCache for EmberService { match resp { ShardResponse::Len(n) => Ok(Response::new(IntResponse { value: n as i64 })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -480,9 +464,7 @@ impl EmberCache for EmberService { match resp { ShardResponse::Bool(v) => Ok(Response::new(BoolResponse { value: v })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -505,9 +487,7 @@ impl EmberCache for EmberService { match resp { ShardResponse::Bool(v) => Ok(Response::new(BoolResponse { value: v })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -524,9 +504,7 @@ impl EmberCache for EmberService { match resp { ShardResponse::Bool(v) => Ok(Response::new(BoolResponse { value: v })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -547,9 +525,7 @@ impl EmberCache for EmberService { })), ShardResponse::Ttl(TtlResult::NoExpiry) => Ok(Response::new(TtlResponse { value: -1 })), ShardResponse::Ttl(TtlResult::NotFound) => Ok(Response::new(TtlResponse { value: -2 })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -570,9 +546,7 @@ impl EmberCache for EmberService { })), ShardResponse::Ttl(TtlResult::NoExpiry) => Ok(Response::new(TtlResponse { value: -1 })), ShardResponse::Ttl(TtlResult::NotFound) => Ok(Response::new(TtlResponse { value: -2 })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -646,9 +620,7 @@ impl EmberCache for EmberService { status: "OK".to_string(), })), ShardResponse::Err(msg) => Err(Status::not_found(msg)), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -735,9 +707,7 @@ impl EmberCache for EmberService { match resp { ShardResponse::Len(n) => Ok(Response::new(IntResponse { value: n as i64 })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -761,9 +731,7 @@ impl EmberCache for EmberService { match resp { ShardResponse::Len(n) => Ok(Response::new(IntResponse { value: n as i64 })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -780,9 +748,7 @@ impl EmberCache for EmberService { value: Some(value_to_bytes(v)), })), ShardResponse::Value(None) => Ok(Response::new(GetResponse { value: None })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -799,9 +765,7 @@ impl EmberCache for EmberService { value: Some(value_to_bytes(v)), })), ShardResponse::Value(None) => Ok(Response::new(GetResponse { value: None })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -827,9 +791,7 @@ impl EmberCache for EmberService { ShardResponse::Array(arr) => Ok(Response::new(ArrayResponse { values: arr.into_iter().map(|b| b.to_vec()).collect(), })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -843,9 +805,7 @@ impl EmberCache for EmberService { match resp { ShardResponse::Len(n) => Ok(Response::new(IntResponse { value: n as i64 })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -874,9 +834,7 @@ impl EmberCache for EmberService { match resp { ShardResponse::Len(n) => Ok(Response::new(IntResponse { value: n as i64 })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -899,9 +857,7 @@ impl EmberCache for EmberService { value: Some(value_to_bytes(v)), })), ShardResponse::Value(None) => Ok(Response::new(GetResponse { value: None })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -926,9 +882,7 @@ impl EmberCache for EmberService { }) .collect(), })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -950,9 +904,7 @@ impl EmberCache for EmberService { ShardResponse::HDelLen { count, .. } => Ok(Response::new(IntResponse { value: count as i64, })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -975,9 +927,7 @@ impl EmberCache for EmberService { match resp { ShardResponse::Bool(v) => Ok(Response::new(BoolResponse { value: v })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -991,9 +941,7 @@ impl EmberCache for EmberService { match resp { ShardResponse::Len(n) => Ok(Response::new(IntResponse { value: n as i64 })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -1017,9 +965,7 @@ impl EmberCache for EmberService { match resp { ShardResponse::Integer(v) => Ok(Response::new(IntResponse { value: v })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -1036,9 +982,7 @@ impl EmberCache for EmberService { match resp { ShardResponse::StringArray(keys) => Ok(Response::new(KeysResponse { keys })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -1057,9 +1001,7 @@ impl EmberCache for EmberService { ShardResponse::Array(arr) => Ok(Response::new(ArrayResponse { values: arr.into_iter().map(|b| b.to_vec()).collect(), })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -1089,9 +1031,7 @@ impl EmberCache for EmberService { }) .collect(), })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -1115,9 +1055,7 @@ impl EmberCache for EmberService { match resp { ShardResponse::Len(n) => Ok(Response::new(IntResponse { value: n as i64 })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -1137,9 +1075,7 @@ impl EmberCache for EmberService { match resp { ShardResponse::Len(n) => Ok(Response::new(IntResponse { value: n as i64 })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -1158,9 +1094,7 @@ impl EmberCache for EmberService { ShardResponse::StringArray(members) => { Ok(Response::new(KeysResponse { keys: members })) } - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -1183,9 +1117,7 @@ impl EmberCache for EmberService { match resp { ShardResponse::Bool(v) => Ok(Response::new(BoolResponse { value: v })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -1202,9 +1134,7 @@ impl EmberCache for EmberService { match resp { ShardResponse::Len(n) => Ok(Response::new(IntResponse { value: n as i64 })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -1240,9 +1170,7 @@ impl EmberCache for EmberService { ShardResponse::ZAddLen { count, .. } => Ok(Response::new(IntResponse { value: count as i64, })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -1264,9 +1192,7 @@ impl EmberCache for EmberService { ShardResponse::ZRemLen { count, .. } => Ok(Response::new(IntResponse { value: count as i64, })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -1289,9 +1215,7 @@ impl EmberCache for EmberService { match resp { ShardResponse::Score(s) => Ok(Response::new(OptionalFloatResponse { value: s })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -1316,9 +1240,7 @@ impl EmberCache for EmberService { ShardResponse::Rank(r) => Ok(Response::new(OptionalIntResponse { value: r.map(|n| n as i64), })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -1335,9 +1257,7 @@ impl EmberCache for EmberService { match resp { ShardResponse::Len(n) => Ok(Response::new(IntResponse { value: n as i64 })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } } @@ -1376,9 +1296,7 @@ impl EmberCache for EmberService { }) .collect(), })), - other => { - Err(unexpected_response(&other)) - } + other => Err(unexpected_response(&other)), } }