refactor: replace FromResponse trait with fetch_inner + fetch_conditional - #373
Closed
JanKaul wants to merge 1 commit into
Closed
refactor: replace FromResponse trait with fetch_inner + fetch_conditional#373JanKaul wants to merge 1 commit into
JanKaul wants to merge 1 commit into
Conversation
…onal - Extract HTTP mechanics into private fetch_inner returning reqwest::Response - fetch becomes a thin wrapper (T: DeserializeOwned), absorbing fetch_empty - fetch_conditional returns Conditional<T> for 304-aware endpoints - Conditional::Modified now carries the full HeaderMap instead of a single extracted etag string, letting callers access any response header - load_table is non-generic, always returns Conditional<LoadTableResult> - No FromResponse trait needed; no fetch_empty function needed
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.
Builds on #372.
Summary
FromResponsesingle-method async trait entirelyfetch_innerthat returns a rawreqwest::Responsefetchbecomes a thin wrapper overfetch_innerwithT: DeserializeOwned, absorbingfetch_empty(which is deleted)fetch_conditionalis a new thin wrapper that handles 304 Not Modified and returnsConditional<T>Conditional::Modifiednow carries the fullreqwest::header::HeaderMapinstead of just an extractedetag: Option<String>, giving callers access to any response headerload_tableis no longer generic — it always returnsConditional<LoadTableResult>and callsfetch_conditionaldirectlyMotivation
FromResponseis a single-method trait with no state, which is the textbook case for replacement with a function. Thefetch_inner+ two thin wrappers pattern achieves the same zero-duplication benefit with no public trait surface to maintain or explain. Returning the fullHeaderMapfromConditional::Modifiedis strictly more general than pre-extracting only the ETag.