-
Notifications
You must be signed in to change notification settings - Fork 184
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
IterableDataProvider::supported_locales is a misnomer #4872
Comments
I believe this should be fn supported_requests(&self) -> Result<HashSet<DataRequest>, DataError> This is because after moving key attributes to the request, supported-locales is not enough to enumerate all supported requests. And if we're using the "requests" phrasing, this will not clash with the notion of supported locales. Also, for performance, I'd like this to return a |
I see you implemented this in #4981 I'm still a little worried about calling it "supported", since the set of supported requests is not finite, but it is not as bad as "supported locales". Calling it "iter" takes away any notion of the semantics of the return value. |
I made the change from |
Yes, those two changes are good. I would say to use |
As part of fixing this, we should make the value of the HashSet be something that can implement |
I suggested up there that Such a struct could be a field of |
^ If we use this name, the function can be called |
No, because we use the fact that locale and attributes can be independently borrowed in fallback. |
It would be another public exhaustive struct so things could still be borrowed separately |
A struct over two borrowed values cannot be borrowed as a struct over the owned values. The pair we're currently using is basically a struct, so the problem is not solved by having a struct. Re name, what about |
Maybe just make them both cows? pub struct LocaleAndAttributes<'a, 'b> {
pub locale: Cow<'a, DataLocale>, // or LanguageIdentifier
pub key_attributes: Cow<'b, KeyAttributes>, // or KeyAttributes<'b>
} I'd rather have the indirection than all the extra cloning.
Maybe but I'm not sure "allowed" is much better than "supported". They both make it sound like these are the only requests you can pass in, but you can pass in any request. |
Yes I'm using |
Preliminary discussion: struct DataIdentityOwned { pub locale: DataLocale, pub marker_attributes: DataMarkerAttributes }
struct DataIdentityBorrowed<'a> { pub locale: &'a DataLocale, pub marker_attributes: &'a DataMarkerAttributes }
struct DataRequest<'a> { id: DataIdentityBorrowed<'a>, metadata: DataRequestMetadata }
/// A [`DataProvider`] that can iterate over all supported [`DataLocale`] for a certain marker.
///
/// Implementing this trait means that a data provider knows all of the data it can successfully
/// return from a load request.
pub trait IterableDataProvider<M: DataMarker>: DataProvider<M> {
/// Returns a list of supported `DataRequests`, in owned form.
fn iter_requests(&self) -> Result<BTreeSet<DataIdentityOwned>, DataError>;
}
pub trait Bikeshed<M: DataMarker>: DataProvider<M> {
fn can_load(&self, req: DataRequest) -> Result<bool, DataError>;
}
|
@robertbastian What is left on this issue? |
Nothing. |
Now that we have a more well-established notion of a "supported locale" (#58), we should rename this trait function.
I suggest:
iter_locales
, and maybe make it return an iterator (if not too hard).The text was updated successfully, but these errors were encountered: