Summary
Refactor the codebase to encapsulate each display block so that it can declare required resources and render its own output.
Current State
- Data fetching is centralized in
SteamClient
- Display rendering is handled separately in
display.rs
- Adding new blocks requires changes in multiple places
Proposed Design
Each display block should:
- Declare what resources it needs (not fetch directly)
- Render its own output using fetched resources
// Example concept
enum Resource {
Player,
OwnedGames,
Achievements,
SteamLevel,
RecentlyPlayed,
}
trait DisplayBlock {
fn required_resources(&self) -> Vec<Resource>;
fn render(&self, resources: &ResourceStore) -> Vec<String>;
}
// Fetcher collects all required resources from blocks,
// deduplicates, and fetches them once
struct ResourceFetcher { ... }
Benefits
- Shared resources (e.g., OwnedGames) fetched only once
- Easier to add/remove/reorder display blocks
- Better separation of concerns
- Each block can manage its own caching strategy
- More testable components
Summary
Refactor the codebase to encapsulate each display block so that it can declare required resources and render its own output.
Current State
SteamClientdisplay.rsProposed Design
Each display block should:
Benefits