diff --git a/bindings/c/include/opendal.h b/bindings/c/include/opendal.h index bc47bf5b541f..95c0be52d2a6 100644 --- a/bindings/c/include/opendal.h +++ b/bindings/c/include/opendal.h @@ -96,6 +96,8 @@ typedef struct BlockingLister BlockingLister; * * # Examples * + * ## Init backends + * * Read more backend init examples in [`services`] * * ``` @@ -103,8 +105,8 @@ typedef struct BlockingLister BlockingLister; * 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. @@ -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;