use async_trait::async_trait;
use futures_core::future::BoxFuture;
use std::future::Future;
use std::time::Duration;
use tokio::runtime::Handle;
use ve_tos_rust_sdk::asynchronous::bucket::BucketAPI;
use ve_tos_rust_sdk::asynchronous::tos;
use ve_tos_rust_sdk::asynchronous::tos::AsyncRuntime;
use ve_tos_rust_sdk::bucket::ListBucketCustomDomainInput;
use ve_tos_rust_sdk::error::TosError;
#[derive(Debug, Default)]
pub struct TokioRuntime {}
impl AsyncRuntime for TokioRuntime {
type JoinError = tokio::task::JoinError;
async fn sleep(&self, duration: Duration) {
tokio::time::sleep(duration).await;
fn spawn<'a, F>(&self, future: F) -> BoxFuture<'a, Result<F::Output, Self::JoinError>>
F: Future + Send + 'static,
F::Output: Send + 'static,
Box::pin(Handle::current().spawn(future))
fn block_on<F: Future>(&self, future: F) -> F::Output {
Handle::current().block_on(future)
let ak = env::var("TOS_ACCESS_KEY").unwrap_or_else(|_| "".to_string());
let sk = env::var("TOS_SECRET_KEY").unwrap_or_else(|_| "".to_string());
let endpoint = "https://tos-cn-beijing.volces.com";
let region = "cn-beijing";
let client = tos::builder::<TokioRuntime>()
.connection_timeout(3000)
let input = ListBucketCustomDomainInput::new("<YOUR_BUCKET_NAME>");
match client.list_bucket_custom_domain(&input).await {
println!("成功获取自定义域名列表");
for domain in output.rules() {
println!("域名: {}", domain.domain());
println!("证书ID: {}", domain.cert_id());
println!("证书状态: {}", domain.cert_status());
println!("协议类型: {}", domain.protocol());
println!("是否禁用: {}", domain.forbidden());
println!("禁用原因: {}", domain.forbidden_reason());
eprintln!("获取自定义域名列表失败: {:?}", err);