Skip to content

Commit

Permalink
feat: implement fetch transform for source
Browse files Browse the repository at this point in the history
  • Loading branch information
ten3roberts committed Jun 2, 2024
1 parent bf8aa90 commit bf6dc00
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/fetch/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
Entity, Fetch, FetchItem,
};

use super::{FetchAccessData, FetchPrepareData, PreparedFetch, RandomFetch};
use super::{FetchAccessData, FetchPrepareData, PreparedFetch, RandomFetch, TransformFetch};

pub trait FetchSource {
fn resolve<'a, 'w, Q: Fetch<'w>>(
Expand Down Expand Up @@ -266,6 +266,21 @@ pub struct PreparedSource<'w, Q> {
_marker: PhantomData<&'w mut ()>,
}

impl<Q, K, S> TransformFetch<K> for Source<Q, S>
where
Q: TransformFetch<K>,
S: FetchSource,
{
type Output = Source<Q::Output, S>;

fn transform_fetch(self, method: K) -> Self::Output {
Source {
fetch: self.fetch.transform_fetch(method),
source: self.source,
}
}
}

#[cfg(test)]
mod test {
use itertools::Itertools;
Expand Down

0 comments on commit bf6dc00

Please sign in to comment.