refactor: aof serialization helpers and snapshot utf-8 helper#130
Merged
Conversation
added AofRecord::tag() that maps each variant to its on-disk tag byte. moved the write_u8(tag) call before the match, then combined variants with identical serialization shapes: - key-only: Del | LPop | RPop | Persist | Incr | Decr - key + byte list: LPush | RPush - key + string list: ZRem | SAdd | SRem - key + i64: IncrBy | DecrBy each group writes the tag once via self.tag(), then shares the payload serialization logic. unique variants (ZAdd, HSet, VAdd, etc.) keep their own arms with section comments.
the pattern String::from_utf8(bytes).map_err(|_| FormatError::Io(...)) was repeated 6 times across read_plaintext_entry. extracted a parse_utf8 helper that takes the bytes and a field name for the error message. also wired the existing read_snap_string (encryption path) to use it.
kacy
added a commit
that referenced
this pull request
Feb 19, 2026
* refactor: add tag() method, combine aof serialization patterns added AofRecord::tag() that maps each variant to its on-disk tag byte. moved the write_u8(tag) call before the match, then combined variants with identical serialization shapes: - key-only: Del | LPop | RPop | Persist | Incr | Decr - key + byte list: LPush | RPush - key + string list: ZRem | SAdd | SRem - key + i64: IncrBy | DecrBy each group writes the tag once via self.tag(), then shares the payload serialization logic. unique variants (ZAdd, HSet, VAdd, etc.) keep their own arms with section comments. * refactor: extract parse_utf8 helper in snapshot deserialization the pattern String::from_utf8(bytes).map_err(|_| FormatError::Io(...)) was repeated 6 times across read_plaintext_entry. extracted a parse_utf8 helper that takes the bytes and a field name for the error message. also wired the existing read_snap_string (encryption path) to use it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
summary
aof.rs:
AofRecord::tag()method mapping each variant to its on-disk tag bytewrite_u8(tag)call above the match so all arms share it|patterns:snapshot.rs:
parse_utf8(bytes, field)helper for theString::from_utf8 + map_errpattern that was repeated 6 times inread_plaintext_entryread_snap_string(encryption path) to use it toowhat was tested
cargo test -p ember-persistence --features vector,protobuf— all 76 tests passcargo clippy -p ember-persistence --features vector,protobuf -- -D warnings— clean