-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Summary
The Key and Value traits have a circular dependency - each requires the other as an associated type.
Location
crates/kvapi/src/kvapi/key.rs:52-57
pub trait Key: KeyCodec + Debug {
type ValueType: kvapi::Value; // Key knows about Value
// ...
}crates/kvapi/src/kvapi/value.rs:20-21
pub trait Value: Debug {
type KeyType: kvapi::Key; // Value knows about Key
// ...
}Problem
This circular dependency:
- Makes the traits harder to understand and implement separately
- Creates unnecessary coupling between key and value abstractions
- Complicates trait bounds in generic code
- Prevents implementing one trait without the other
Impact
- More complex generic signatures throughout the codebase
- Harder to add new key or value types
- Cognitive overhead when working with the API
Suggested Fix
Consider whether Value::KeyType is truly necessary. The dependency_keys() method could potentially accept string keys instead:
pub trait Value: Debug {
// Remove KeyType association if not strictly needed
fn dependency_keys(&self, key: &str) -> impl IntoIterator<Item = String>;
}Or if bidirectional navigation is needed, use a separate KeyValuePair trait that brings them together.
Priority
P2 - API design improvement
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request