Skip to content

Commit

Permalink
Update opendal.h
Browse files Browse the repository at this point in the history
Signed-off-by: Xuanwo <[email protected]>
  • Loading branch information
Xuanwo committed Sep 18, 2023
1 parent 64d8318 commit d701c67
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions bindings/c/include/opendal.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,17 @@ typedef struct BlockingLister BlockingLister;
*
* # Examples
*
* ## Init backends
*
* Read more backend init examples in [`services`]
*
* ```
* # use anyhow::Result;
* use opendal::services::Fs;
* use opendal::BlockingOperator;
* use opendal::Operator;
* #[tokio::main]
* async fn main() -> Result<()> {
*
* fn main() -> Result<()> {
* // Create fs backend builder.
* let mut builder = Fs::default();
* // Set the root for fs, all operations will happen under this root.
Expand All @@ -118,6 +120,35 @@ typedef struct BlockingLister BlockingLister;
* Ok(())
* }
* ```
*
* ## Init backends with blocking layer
*
* Some services like s3, gcs doesn't have native blocking supports, we can use [`layers::BlockingLayer`]
* to wrap the async operator to make it blocking.
*
* ```rust
* # use anyhow::Result;
* use opendal::layers::BlockingLayer;
* use opendal::services::S3;
* use opendal::BlockingOperator;
* use opendal::Operator;
*
* #[tokio::main]
* async fn main() -> Result<()> {
* // Create fs backend builder.
* let mut builder = S3::default();
* builder.bucket("test");
* builder.region("us-east-1");
*
* // Build an `BlockingOperator` with blocking layer to start operating the storage.
* let _: BlockingOperator = Operator::new(builder)?
* .layer(BlockingLayer::create()?)
* .finish()
* .blocking();
*
* Ok(())
* }
* ```
*/
typedef struct BlockingOperator BlockingOperator;

Expand Down

0 comments on commit d701c67

Please sign in to comment.