diff options
Diffstat (limited to '')
-rw-r--r-- | third_party/rust/remote_settings/.cargo-checksum.json | 2 | ||||
-rw-r--r-- | third_party/rust/remote_settings/Cargo.toml | 4 | ||||
-rw-r--r-- | third_party/rust/remote_settings/src/client.rs | 54 |
3 files changed, 32 insertions, 28 deletions
diff --git a/third_party/rust/remote_settings/.cargo-checksum.json b/third_party/rust/remote_settings/.cargo-checksum.json index 8a2b63f314..619a9d13ca 100644 --- a/third_party/rust/remote_settings/.cargo-checksum.json +++ b/third_party/rust/remote_settings/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"4fa89b0606fe8ec8ac8c479b8b9adf33d0c936b09fa5af108ded74139ace37fb","build.rs":"4326f03729cf8f1673e4228e6dc111de1ea4d8bcc06351f7ae563efb2613f866","src/client.rs":"fb3f2cd47460e5ae07a5e8d61b358d588d14075bd9dd6b6e818e1af74abd5dba","src/config.rs":"7bb678addfae3b4ed5f2892d32263e5b33cc05e5a12a250f664150e78211f94a","src/error.rs":"192ca42af7c6b882f3129378c23b45dab8a0d2b179e23a8813a335ffd56b21dc","src/lib.rs":"416e99894e152f6cea7418ad2fabfd94bc3d907efd9f33fbd2a83fb99452b2df","src/remote_settings.udl":"2e71491ad3894d17e5bde0663d9490bfea6294d99cdbe9d67a36137faeedc593","uniffi.toml":"f8ec8dc593e0d501c2e9e40368ec93ec33b1edd8608e29495e0a54b63144e880"},"package":null}
\ No newline at end of file +{"files":{"Cargo.toml":"1029f571c66d33c4dfc5e9fc55287a780329ce183f5d2b672de79737155c4227","build.rs":"4326f03729cf8f1673e4228e6dc111de1ea4d8bcc06351f7ae563efb2613f866","src/client.rs":"7510ae0d5bcb9fbaa2c43c4773aa0fd518edc78fe0f396c0e1d6dd442446f429","src/config.rs":"7bb678addfae3b4ed5f2892d32263e5b33cc05e5a12a250f664150e78211f94a","src/error.rs":"192ca42af7c6b882f3129378c23b45dab8a0d2b179e23a8813a335ffd56b21dc","src/lib.rs":"416e99894e152f6cea7418ad2fabfd94bc3d907efd9f33fbd2a83fb99452b2df","src/remote_settings.udl":"2e71491ad3894d17e5bde0663d9490bfea6294d99cdbe9d67a36137faeedc593","uniffi.toml":"f8ec8dc593e0d501c2e9e40368ec93ec33b1edd8608e29495e0a54b63144e880"},"package":null}
\ No newline at end of file diff --git a/third_party/rust/remote_settings/Cargo.toml b/third_party/rust/remote_settings/Cargo.toml index b04e6ed6c6..71d72079b7 100644 --- a/third_party/rust/remote_settings/Cargo.toml +++ b/third_party/rust/remote_settings/Cargo.toml @@ -28,7 +28,7 @@ license = "MPL-2.0" parking_lot = "0.12" serde_json = "1" thiserror = "1.0" -uniffi = "0.25.2" +uniffi = "0.27.1" url = "2.1" [dependencies.serde] @@ -46,5 +46,5 @@ mockito = "0.31" path = "../support/viaduct-reqwest" [build-dependencies.uniffi] -version = "0.25.2" +version = "0.27.1" features = ["build"] diff --git a/third_party/rust/remote_settings/src/client.rs b/third_party/rust/remote_settings/src/client.rs index 0d99de9cc1..2cf26b7319 100644 --- a/third_party/rust/remote_settings/src/client.rs +++ b/third_party/rust/remote_settings/src/client.rs @@ -64,7 +64,7 @@ impl Client { /// collection defined by the [ClientConfig] used to generate this [Client]. pub fn get_records_since(&self, timestamp: u64) -> Result<RemoteSettingsResponse> { self.get_records_with_options( - GetItemsOptions::new().gt("last_modified", timestamp.to_string()), + GetItemsOptions::new().filter_gt("last_modified", timestamp.to_string()), ) } @@ -307,7 +307,7 @@ struct AttachmentsCapability { } /// Options for requests to endpoints that return multiple items. -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug, Default, Hash, PartialEq, Eq, PartialOrd, Ord)] pub struct GetItemsOptions { filters: Vec<Filter>, sort: Vec<Sort>, @@ -328,14 +328,14 @@ impl GetItemsOptions { /// `author.name`. `value` can be a bare number or string (like /// `2` or `Ben`), or a stringified JSON value (`"2.0"`, `[1, 2]`, /// `{"checked": true}`). - pub fn eq(&mut self, field: impl Into<String>, value: impl Into<String>) -> &mut Self { + pub fn filter_eq(&mut self, field: impl Into<String>, value: impl Into<String>) -> &mut Self { self.filters.push(Filter::Eq(field.into(), value.into())); self } /// Sets an option to only return items whose `field` is not equal to the /// given `value`. - pub fn not(&mut self, field: impl Into<String>, value: impl Into<String>) -> &mut Self { + pub fn filter_not(&mut self, field: impl Into<String>, value: impl Into<String>) -> &mut Self { self.filters.push(Filter::Not(field.into(), value.into())); self } @@ -343,7 +343,11 @@ impl GetItemsOptions { /// Sets an option to only return items whose `field` is an array that /// contains the given `value`. If `value` is a stringified JSON array, the /// field must contain all its elements. - pub fn contains(&mut self, field: impl Into<String>, value: impl Into<String>) -> &mut Self { + pub fn filter_contains( + &mut self, + field: impl Into<String>, + value: impl Into<String>, + ) -> &mut Self { self.filters .push(Filter::Contains(field.into(), value.into())); self @@ -351,47 +355,47 @@ impl GetItemsOptions { /// Sets an option to only return items whose `field` is strictly less /// than the given `value`. - pub fn lt(&mut self, field: impl Into<String>, value: impl Into<String>) -> &mut Self { + pub fn filter_lt(&mut self, field: impl Into<String>, value: impl Into<String>) -> &mut Self { self.filters.push(Filter::Lt(field.into(), value.into())); self } /// Sets an option to only return items whose `field` is strictly greater /// than the given `value`. - pub fn gt(&mut self, field: impl Into<String>, value: impl Into<String>) -> &mut Self { + pub fn filter_gt(&mut self, field: impl Into<String>, value: impl Into<String>) -> &mut Self { self.filters.push(Filter::Gt(field.into(), value.into())); self } /// Sets an option to only return items whose `field` is less than or equal /// to the given `value`. - pub fn max(&mut self, field: impl Into<String>, value: impl Into<String>) -> &mut Self { + pub fn filter_max(&mut self, field: impl Into<String>, value: impl Into<String>) -> &mut Self { self.filters.push(Filter::Max(field.into(), value.into())); self } /// Sets an option to only return items whose `field` is greater than or /// equal to the given `value`. - pub fn min(&mut self, field: impl Into<String>, value: impl Into<String>) -> &mut Self { + pub fn filter_min(&mut self, field: impl Into<String>, value: impl Into<String>) -> &mut Self { self.filters.push(Filter::Min(field.into(), value.into())); self } /// Sets an option to only return items whose `field` is a string that /// contains the substring `value`. `value` can contain `*` wildcards. - pub fn like(&mut self, field: impl Into<String>, value: impl Into<String>) -> &mut Self { + pub fn filter_like(&mut self, field: impl Into<String>, value: impl Into<String>) -> &mut Self { self.filters.push(Filter::Like(field.into(), value.into())); self } /// Sets an option to only return items that have the given `field`. - pub fn has(&mut self, field: impl Into<String>) -> &mut Self { + pub fn filter_has(&mut self, field: impl Into<String>) -> &mut Self { self.filters.push(Filter::Has(field.into())); self } /// Sets an option to only return items that do not have the given `field`. - pub fn has_not(&mut self, field: impl Into<String>) -> &mut Self { + pub fn filter_has_not(&mut self, field: impl Into<String>) -> &mut Self { self.filters.push(Filter::HasNot(field.into())); self } @@ -454,7 +458,7 @@ impl GetItemsOptions { } /// The order in which to return items. -#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)] pub enum SortOrder { /// Smaller values first. Ascending, @@ -462,7 +466,7 @@ pub enum SortOrder { Descending, } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] enum Filter { Eq(String, String), Not(String, String), @@ -495,7 +499,7 @@ impl Filter { } } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] struct Sort(String, SortOrder); impl Sort { @@ -692,16 +696,16 @@ mod test { .field("a") .field("c") .field("b") - .eq("a", "b") - .lt("c.d", "5") - .gt("e", "15") - .max("f", "20") - .min("g", "10") - .not("h", "i") - .like("j", "*k*") - .has("l") - .has_not("m") - .contains("n", "o") + .filter_eq("a", "b") + .filter_lt("c.d", "5") + .filter_gt("e", "15") + .filter_max("f", "20") + .filter_min("g", "10") + .filter_not("h", "i") + .filter_like("j", "*k*") + .filter_has("l") + .filter_has_not("m") + .filter_contains("n", "o") .sort("b", SortOrder::Descending) .sort("a", SortOrder::Ascending) .limit(3); |