File tree 2 files changed +53
-2
lines changed
2 files changed +53
-2
lines changed Original file line number Diff line number Diff line change @@ -673,11 +673,43 @@ impl BlockingOperator {
673
673
/// # }
674
674
/// ```
675
675
pub fn delete ( & self , path : & str ) -> Result < ( ) > {
676
+ self . delete_with ( path) . call ( ) ?;
677
+
678
+ Ok ( ( ) )
679
+ }
680
+
681
+ /// Delete given path with options.
682
+ ///
683
+ /// # Notes
684
+ ///
685
+ /// - Delete not existing error won't return errors.
686
+ ///
687
+ /// # Examples
688
+ ///
689
+ /// ```no_run
690
+ /// # use anyhow::Result;
691
+ /// # use futures::io;
692
+ /// # use opendal::BlockingOperator;
693
+ /// # fn test(op: BlockingOperator) -> Result<()> {
694
+ /// let _ = op
695
+ /// .delete_with("path/to/file")
696
+ /// .version("example_version").call()?;
697
+ /// # Ok(())
698
+ /// # }
699
+ /// ```
700
+ pub fn delete_with ( & self , path : & str ) -> FunctionDelete {
676
701
let path = normalize_path ( path) ;
677
702
678
- let _ = self . inner ( ) . blocking_delete ( & path, OpDelete :: new ( ) ) ?;
703
+ FunctionDelete ( OperatorFunction :: new (
704
+ self . inner ( ) . clone ( ) ,
705
+ path,
706
+ OpDelete :: new ( ) ,
707
+ |inner, path, args| {
708
+ let _ = inner. blocking_delete ( & path, args) ?;
679
709
680
- Ok ( ( ) )
710
+ Ok ( ( ) )
711
+ } ,
712
+ ) )
681
713
}
682
714
683
715
/// remove will remove files via the given paths.
Original file line number Diff line number Diff line change @@ -95,3 +95,22 @@ impl FunctionWrite {
95
95
self . 0 . call ( )
96
96
}
97
97
}
98
+
99
+ /// Function that generated by [`BlockingOperator::delete_with`].
100
+ ///
101
+ /// Users can add more options by public functions provided by this struct.
102
+ pub struct FunctionDelete ( pub ( crate ) OperatorFunction < OpDelete , ( ) > ) ;
103
+
104
+ impl FunctionDelete {
105
+ /// Set the version for this operation.
106
+ pub fn version ( mut self , v : & str ) -> Self {
107
+ self . 0 = self . 0 . map_args ( |args| args. with_version ( v) ) ;
108
+ self
109
+ }
110
+
111
+ /// Call the function to consume all the input and generate a
112
+ /// result.
113
+ pub fn call ( self ) -> Result < ( ) > {
114
+ self . 0 . call ( )
115
+ }
116
+ }
You can’t perform that action at this time.
0 commit comments