Skip to content

feat: PlainStateProvider returns key-value pairs with version tracking#117

Open
deepld wants to merge 4 commits intomainfrom
deep_extend
Open

feat: PlainStateProvider returns key-value pairs with version tracking#117
deepld wants to merge 4 commits intomainfrom
deep_extend

Conversation

@deepld
Copy link
Collaborator

@deepld deepld commented Jan 29, 2026

Summary

Enhance PlainStateProvider to return version information alongside key-value pairs, enabling downstream consumers to track state changes and implement version-aware caching strategies.

Key API Change:

// Before
pub fn plain_value(&self, plain_key: &[u8], hint: Option<BucketId>) 
    -> Result<Option<Vec<u8>>, S::Error>

// After  
pub fn plain_value(&self, plain_key: &[u8], hint: Option<BucketId>)
    -> Result<Option<(SaltValue, SaltVersion)>, S::Error>

Changes

  • New type: SaltVersion (u64) for tracking state value versions
  • Trait extension: Added StateReader::value_with_version() with backward-compatible default implementation
  • API enhancement: PlainStateProvider::plain_value() now returns (SaltValue, SaltVersion) tuple
  • Refactoring: Generalized internal search functions to eliminate code duplication
  • Optimization: Added #[repr(align(8))] to SaltValue for improved memory alignment

Backward Compatibility

✅ Existing StateReader implementations continue to work without modification - the default value_with_version() implementation returns version 0

⚠️ Breaking Change: Callers of PlainStateProvider::plain_value() must update to handle the new return type

Refactor search functions to support version tracking:
- Make shi_search_with_version generic to accept any extra data type
- Reuse generic helper in shi_search to eliminate code duplication
- Add inline attribute for performance optimization
@deepld deepld changed the title feat: add version tracking support to PlainStateProvider feat: PlainStateProvider returns key-value pairs with version tracking Jan 29, 2026
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.

1 participant