Skip to content

Conversation

konard
Copy link
Member

@konard konard commented Sep 11, 2025

🎯 Summary

This PR implements the solution for issue #6 by reversing the trait relationship between Links and Doublets traits.

📋 Issue Reference

Fixes #6

🔄 Changes Made

1. Trait Hierarchy Refactoring

  • Before: pub trait Doublets<T: LinkType>: Links<T>
  • After: pub trait Doublets<T: LinkType>: Send + Sync

2. Core Methods Integration

Moved all core Links trait methods into the Doublets trait:

  • constants(&self) -> &LinksConstants<T>
  • count_links(&self, query: &[T]) -> T
  • create_links(...), each_links(...), update_links(...), delete_links(...)
  • get_link(&self, index: T) -> Option<Link<T>>

3. Blanket Implementation

Added automatic Links implementation for any type implementing Doublets:

impl<T: LinkType, D: Doublets<T> + ?Sized> Links<T> for D {
    // Delegates all methods to the Doublets implementation
}

4. Store Implementation Update

  • Before: Implemented both Links<T> and Doublets<T> for Store
  • After: Only implements Doublets<T>, automatically gets Links<T> via blanket impl

🎉 Benefits

  1. Better Error Handling: As mentioned in the issue, this addresses the error handling improvements in the data-rs repository
  2. Cleaner Architecture: impl Links for Doublets instead of Doublets for Links
  3. Reduced Boilerplate: Automatic Links implementation for all Doublets types
  4. Backward Compatibility: All existing APIs continue to work unchanged

🧪 Testing

The implementation maintains full API compatibility. All existing code using either Links or Doublets traits will continue to work without changes.

🔗 Related


🤖 Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #6
@konard konard self-assigned this Sep 11, 2025
konard and others added 2 commits September 11, 2025 13:55
This change addresses issue #6 by reversing the trait relationship:
- Remove inheritance from Doublets<T>: Links<T>
- Add blanket implementation impl<T, D: Doublets<T>> Links<T> for D
- Move core Links methods into Doublets trait
- Update Store to only implement Doublets, getting Links automatically

This approach follows the issue suggestion to "impl Links for Doublets"
instead of "Doublets for Links", providing better error handling as
mentioned in the data-rs repository commit a2cadfa.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@konard konard changed the title [WIP] Use Links trait from data Implement Links trait for Doublets instead of trait inheritance Sep 11, 2025
@konard konard marked this pull request as ready for review September 11, 2025 11:03
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.

Use Links trait from data

1 participant