You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "meteorgan (via GitHub)" <gi...@apache.org> on 2025/04/05 12:21:06 UTC

[PR] chore(core/types): rename with_user_metadata to set_user_metadata to maintain consistency with other methods in the metadata [opendal]

meteorgan opened a new pull request, #5960:
URL: https://github.com/apache/opendal/pull/5960

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   None
   
   # Rationale for this change
   
   Currently, `with_user_metadata` in the metadata module has a similar signature to the `set_xxx` methods, but the difference in naming can be confusing.
   
   <!--
   Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
   Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
   -->
   
   # What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   # Are there any user-facing changes?
   None
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!---
   If there are any breaking changes to public APIs, please add the `breaking-changes` label.
   -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] chore(core/types): rename `with_user_metadata` to `set_user_metadata` [opendal]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on code in PR #5960:
URL: https://github.com/apache/opendal/pull/5960#discussion_r2030116755


##########
core/src/types/metadata.rs:
##########
@@ -429,7 +429,7 @@ impl Metadata {
     }
 
     /// Set user defined metadata of this entry
-    pub fn with_user_metadata(&mut self, data: HashMap<String, String>) -> &mut Self {
+    pub fn set_user_metadata(&mut self, data: HashMap<String, String>) -> &mut Self {

Review Comment:
   Hi, BytesContentRange and Duration are Copy.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] chore(core/types): fix `with_user_metadata` signature [opendal]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on PR #5960:
URL: https://github.com/apache/opendal/pull/5960#issuecomment-2897333540

   We are ready to go!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] chore(core/types): rename `with_user_metadata` to `set_user_metadata` [opendal]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on code in PR #5960:
URL: https://github.com/apache/opendal/pull/5960#discussion_r2029869379


##########
core/src/types/metadata.rs:
##########
@@ -429,7 +429,7 @@ impl Metadata {
     }
 
     /// Set user defined metadata of this entry
-    pub fn with_user_metadata(&mut self, data: HashMap<String, String>) -> &mut Self {
+    pub fn set_user_metadata(&mut self, data: HashMap<String, String>) -> &mut Self {

Review Comment:
   The difference between `with_xxx` and `set_xxx` is:
   
   - `with_xxx` accepts an owned type, requiring no `Copy` or `Clone`, but it consumes `self`.
   - `set_xxx` accepts a borrowed type, which may require an additional clone, but only needs `&mut self`.
   
   The current API sits somewhere in between these two approaches. It might be better to change it to `with_user_metadata(mut self, data)` instead.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] refactor(core/types)!: fix `with_user_metadata` signature [opendal]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo merged PR #5960:
URL: https://github.com/apache/opendal/pull/5960


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] chore(core/types): fix `with_user_metadata` signature [opendal]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on PR #5960:
URL: https://github.com/apache/opendal/pull/5960#issuecomment-2781445532

   Thank you @meteorgan for this! I have marked this as `breaking-change`. Let's hold on this PR until next major release.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] chore(core/types): rename `with_user_metadata` to `set_user_metadata` [opendal]

Posted by "meteorgan (via GitHub)" <gi...@apache.org>.
meteorgan commented on code in PR #5960:
URL: https://github.com/apache/opendal/pull/5960#discussion_r2030111767


##########
core/src/types/metadata.rs:
##########
@@ -429,7 +429,7 @@ impl Metadata {
     }
 
     /// Set user defined metadata of this entry
-    pub fn with_user_metadata(&mut self, data: HashMap<String, String>) -> &mut Self {
+    pub fn set_user_metadata(&mut self, data: HashMap<String, String>) -> &mut Self {

Review Comment:
   > * `set_xxx` accepts a borrowed type, 
   
   This is not always true.  Both `set_content_range` and `set_last_modified` also accept an owned type. In current implementation, `set_xxx` is typically used when the returned value is not needed.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org