static_

Crates.iostatic_
lib.rsstatic_
version0.1.14
created_at2025-01-22 10:08:06.31661+00
updated_at2025-01-23 03:53:08.92812+00
descriptioninit async as global static
homepagehttps://github.com/i18n-site/rust/tree/main/static_
repositoryhttps://github.com/i18n-site/rust.git
max_upload_size
id1526469
size23,155
i18n.site (i18nsite)

documentation

README

static_

use aok::{Result, OK};
use tokio::time::{sleep, Duration};
use tracing::info;

pub struct Client {}

impl Client {
  pub async fn test(&self) {
    info!("client test success");
  }
}

pub async fn connect() -> Result<Client> {
  info!("Sleeping for 3 seconds...");
  sleep(Duration::from_secs(3)).await;
  Ok(Client {})
}

static_::init!(CLIENT: Client {
  connect().await
});

#[tokio::main]
async fn main() -> Result<()> {
  static_::init().await?;
  info!("inited");
  CLIENT.test().await;
  OK
}

About

This project is an open-source component of i18n.site ⋅ Internationalization Solution.

关于

本项目为 i18n.site ⋅ 国际化解决方案 的开源组件。

Commit count: 68

cargo fmt