erickguan commented on code in PR #7815:
URL: https://github.com/apache/opendal/pull/7815#discussion_r3487872470
##########
core/core/src/types/operator/operator.rs:
##########
@@ -1389,24 +1389,111 @@ impl Operator {
/// # }
/// ```
pub async fn rename(&self, from: &str, to: &str) -> Result<()> {
+ self.rename_options(from, to, options::RenameOptions::default())
+ .await
+ }
+
+ /// Rename a file from `from` to `to` with additional options.
+ ///
+ /// # Notes
+ ///
+ /// - `from` and `to` must be a file.
+ /// - If `from` and `to` are the same, an `IsSameFile` error will occur.
+ ///
+ /// # Options
+ ///
+ /// Visit [`options::RenameOptions`] for all available options.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use opendal_core::Operator;
+ /// use opendal_core::Result;
+ ///
+ /// async fn rename_with_options(op: Operator) -> Result<()> {
+ /// op.rename_with("path/to/file", "path/to/file2")
+ /// .if_not_exists(true)
+ /// .await?;
+ /// Ok(())
+ /// }
+ /// ```
+ pub fn rename_with(
+ &self,
+ from: &str,
+ to: &str,
+ ) -> FutureRename<impl Future<Output = Result<()>>> {
let from = normalize_path(from);
+ let to = normalize_path(to);
+
+ OperatorFuture::new(
+ self.context().clone(),
+ self.service().clone(),
+ from,
+ (options::RenameOptions::default(), to),
+ Self::rename_inner,
+ )
+ }
+ /// Rename a file from `from` to `to` with additional options.
+ ///
+ /// # Options
+ ///
+ /// Visit [`options::RenameOptions`] for all available options.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use opendal_core::options::RenameOptions;
+ /// use opendal_core::Operator;
+ /// use opendal_core::Result;
+ ///
+ /// async fn test(op: Operator) -> Result<()> {
Review Comment:
```suggestion
/// async fn rename_with_test(op: Operator) -> Result<()> {
```
Better to provide some information in a documentation.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]