From 1ee401408c6c5ec78b229f9cea556dbb583d296b Mon Sep 17 00:00:00 2001 From: andrew <> Date: Sat, 6 Jan 2024 13:17:16 +0900 Subject: [PATCH 1/3] Make field mask inner public --- google-apis-common/src/field_mask.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google-apis-common/src/field_mask.rs b/google-apis-common/src/field_mask.rs index f84dcf4f108..67a72c95c0a 100644 --- a/google-apis-common/src/field_mask.rs +++ b/google-apis-common/src/field_mask.rs @@ -32,7 +32,7 @@ fn snakecase(source: &str) -> String { /// A `FieldMask` as defined in `https://github.com/protocolbuffers/protobuf/blob/ec1a70913e5793a7d0a7b5fbf7e0e4f75409dd41/src/google/protobuf/field_mask.proto#L180` #[derive(Clone, Debug, Default, PartialEq, Eq)] -pub struct FieldMask(Vec); +pub struct FieldMask(pub Vec); impl Serialize for FieldMask { fn serialize(&self, s: S) -> Result From 157b45f6064b9d2c95c2b7057c60875312530103 Mon Sep 17 00:00:00 2001 From: andrew <> Date: Sat, 6 Jan 2024 17:42:03 +0900 Subject: [PATCH 2/3] Add FieldMask new method instead of making internals public --- google-apis-common/src/field_mask.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/google-apis-common/src/field_mask.rs b/google-apis-common/src/field_mask.rs index 67a72c95c0a..3bd63b69567 100644 --- a/google-apis-common/src/field_mask.rs +++ b/google-apis-common/src/field_mask.rs @@ -32,7 +32,13 @@ fn snakecase(source: &str) -> String { /// A `FieldMask` as defined in `https://github.com/protocolbuffers/protobuf/blob/ec1a70913e5793a7d0a7b5fbf7e0e4f75409dd41/src/google/protobuf/field_mask.proto#L180` #[derive(Clone, Debug, Default, PartialEq, Eq)] -pub struct FieldMask(pub Vec); +pub struct FieldMask(Vec); + +impl FieldMask { + pub fn new>(values: &[S]) -> Self { + return Self(values.iter().map(|s| snakecase(s.as_ref())).collect()); + } +} impl Serialize for FieldMask { fn serialize(&self, s: S) -> Result From d09893e9212be1f346f6fe8ca61d39ff6c8b8232 Mon Sep 17 00:00:00 2001 From: andrew <> Date: Sat, 6 Jan 2024 18:57:31 +0900 Subject: [PATCH 3/3] Add docstring --- google-apis-common/src/field_mask.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/google-apis-common/src/field_mask.rs b/google-apis-common/src/field_mask.rs index 3bd63b69567..3d8220a921a 100644 --- a/google-apis-common/src/field_mask.rs +++ b/google-apis-common/src/field_mask.rs @@ -35,6 +35,8 @@ fn snakecase(source: &str) -> String { pub struct FieldMask(Vec); impl FieldMask { + /// Create a new `FieldMask` from a list of paths. These are converted to snake + /// case if they aren't already. pub fn new>(values: &[S]) -> Self { return Self(values.iter().map(|s| snakecase(s.as_ref())).collect()); }