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

Returning ExtraneousLocale in BlobDataProvider #3562

Merged
merged 3 commits into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions provider/blob/src/blob_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ impl<'data> BlobSchemaV1<'data> {
.get0(&key.hashed())
.ok_or(DataErrorKind::MissingDataKey)
.and_then(|cursor| {
if key.metadata().singleton && !req.locale.is_empty() {
return Err(DataErrorKind::ExtraneousLocale);
}
cursor
.get1_copied_by(|bytes| req.locale.strict_cmp(&bytes.0).reverse())
.ok_or(DataErrorKind::MissingLocale)
Expand Down
16 changes: 2 additions & 14 deletions provider/datagen/src/transform/cldr/fallback/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,8 @@ use zerovec::{maps::ZeroMap2d, ule::UnvalidatedStr};
impl DataProvider<LocaleFallbackLikelySubtagsV1Marker> for crate::DatagenProvider {
fn load(
&self,
req: DataRequest,
_: DataRequest,
) -> Result<DataResponse<LocaleFallbackLikelySubtagsV1Marker>, DataError> {
// We treat searching for `und` as a request for all data. Other requests
// are not currently supported.
if !req.locale.is_empty() {
return Err(DataErrorKind::ExtraneousLocale.into_error());
}

let resources = LikelySubtagsResources::try_from_source_data(&self.source)?;

let metadata = DataResponseMetadata::default();
Expand All @@ -42,14 +36,8 @@ impl DataProvider<LocaleFallbackLikelySubtagsV1Marker> for crate::DatagenProvide
impl DataProvider<LocaleFallbackParentsV1Marker> for crate::DatagenProvider {
fn load(
&self,
req: DataRequest,
_: DataRequest,
) -> Result<DataResponse<LocaleFallbackParentsV1Marker>, DataError> {
// We treat searching for `und` as a request for all data. Other requests
// are not currently supported.
if !req.locale.is_empty() {
return Err(DataErrorKind::ExtraneousLocale.into_error());
}

let parents_data: &cldr_serde::parent_locales::Resource = self
.source
.cldr()?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@ use tinystr::TinyAsciiStr;
use zerovec::ZeroSlice;

impl DataProvider<AliasesV1Marker> for crate::DatagenProvider {
fn load(&self, req: DataRequest) -> Result<DataResponse<AliasesV1Marker>, DataError> {
// We treat searching for `und` as a request for all data. Other requests
// are not currently supported.
if !req.locale.is_empty() {
return Err(DataErrorKind::ExtraneousLocale.into_error());
}

fn load(&self, _: DataRequest) -> Result<DataResponse<AliasesV1Marker>, DataError> {
let data: &cldr_serde::aliases::Resource = self
.source
.cldr()?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@ use icu_provider::datagen::IterableDataProvider;
use icu_provider::prelude::*;

impl DataProvider<ScriptDirectionV1Marker> for crate::DatagenProvider {
fn load(&self, req: DataRequest) -> Result<DataResponse<ScriptDirectionV1Marker>, DataError> {
// We treat searching for `und` as a request for all data. Other requests
// are not currently supported.
if !req.locale.is_empty() {
return Err(DataErrorKind::ExtraneousLocale.into_error());
}

fn load(&self, _: DataRequest) -> Result<DataResponse<ScriptDirectionV1Marker>, DataError> {
let data: &cldr_serde::directionality::Resource = self
.source
.cldr()?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@ use icu_provider::prelude::*;
use std::collections::{BTreeMap, HashSet};

impl DataProvider<LikelySubtagsV1Marker> for crate::DatagenProvider {
fn load(&self, req: DataRequest) -> Result<DataResponse<LikelySubtagsV1Marker>, DataError> {
// We treat searching for und as a request for all data. Other requests
// are not currently supported.
if !req.locale.is_empty() {
return Err(DataErrorKind::ExtraneousLocale.into_error());
}

fn load(&self, _: DataRequest) -> Result<DataResponse<LikelySubtagsV1Marker>, DataError> {
let resources = LikelySubtagsResources::try_from_source_data(&self.source)?;

Ok(DataResponse {
Expand All @@ -37,14 +31,8 @@ impl IterableDataProvider<LikelySubtagsV1Marker> for crate::DatagenProvider {
impl DataProvider<LikelySubtagsExtendedV1Marker> for crate::DatagenProvider {
fn load(
&self,
req: DataRequest,
_: DataRequest,
) -> Result<DataResponse<LikelySubtagsExtendedV1Marker>, DataError> {
// We treat searching for und as a request for all data. Other requests
// are not currently supported.
if !req.locale.is_empty() {
return Err(DataErrorKind::ExtraneousLocale.into_error());
}

let resources = LikelySubtagsResources::try_from_source_data(&self.source)?;

Ok(DataResponse {
Expand Down
Loading