Create service instance (Singleton) in one step
```rust use wildbird::derive::*;
// Convert struct to Service + impl construct()
struct HelloService { component_name: String, }
impl HelloService { fn init() -> HelloService { HelloService { componentname: "Hello penguins 🐧".tostring(), } }
fn say_hello(&self) {
println!("Hello! 👋")
}
}
fn main() {
HelloService.say_hello();
}
- Async init
rust
use wildbird::derive::*;
struct AsyncService {}
impl AsyncService { async fn init() -> AsyncService { AsyncService {} }
fn greeting(&self) {
println!("Hello 🗼")
}
}
fn main() { AsyncService.greeting(); } ``` - Async init functional
```rust use wildbird::derive::*;
// Convert struct to Service
struct HelloService { component_name: String, }
// Impl Service trait construct()
async fn helloinit() -> HelloService {
HelloService {
componentname: "Hello 🚀".to_string(),
}
}
```
Create global ```rust use wildbird::derive::*;
pub fn my_name() -> String { String::from("Hawk 🦅") }
fn main() { println!("Hello from 🇵🇱, {}", &*MY_NAME); } ```
fn custom_name() -> String { std::env::var("HOME").expect("env:HOME not found") }
fn main() { println!("Home: {}", &*HOME); } ```
async fn httpfetchusers() -> String { sleep(Duration::from_millis(200)); String::from("⏱️") } ```
async fn inithttpservice(callback: wildbird::Callback
Cargo.toml
toml
[dependencies]
wildbird = "^0.0.8"
Optional features
toml
[dependencies]
tokio = "1.28.2"
wildbird = {version = "^0.0.8", features = ["tokio"]}
MIT