Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add projection functions to Yoke #829

Closed
sffc opened this issue Jun 28, 2021 · 1 comment · Fixed by #833
Closed

Add projection functions to Yoke #829

sffc opened this issue Jun 28, 2021 · 1 comment · Fixed by #833
Assignees
Labels
A-design Area: Architecture or design C-data-infra Component: provider, datagen, fallback, adapters S-medium Size: Less than a week (larger bug fix or enhancement) T-core Type: Required functionality

Comments

@sffc
Copy link
Member

sffc commented Jun 28, 2021

There are several use cases where we need to project a Yoke from one Yokeable type to another Yokeable type but keeping the same Cart; i.e., map Yoke<A, C> to Yoke<B, C>.

A few examples of use cases:

  1. Yoke<ZeroMap<'static, Foo, Bar>, C> to Yoke<Bar, C> (getting a value from a map)
  2. Yoke<&'static [u8], C> to Yoke<T, C> (applying a deserializer to a slice)
  3. Yoke<T, C> to Yoke<Q, C> where Q is a field of T (selecting more specific data)

I can envision these operations being chained and performed by different data providers. For example, the single-file data provider can return DataPayload<BytesMarker>, which a deserialization provider converts to a DataPayload<LargerDataStructMarker>, which a data filtering provider converts to a DataPayload<SmallerDataStructMarker>.

CC @Manishearth

@sffc sffc added T-core Type: Required functionality C-data-infra Component: provider, datagen, fallback, adapters A-design Area: Architecture or design S-medium Size: Less than a week (larger bug fix or enhancement) labels Jun 28, 2021
@Manishearth
Copy link
Member

I think this can be done safely in a generic fashion but I'm not 100% sure and I need to think about it to figure out the correct bounds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-design Area: Architecture or design C-data-infra Component: provider, datagen, fallback, adapters S-medium Size: Less than a week (larger bug fix or enhancement) T-core Type: Required functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants