pub mod config;
pub mod pool;
use std::{sync::LazyLock, time::Duration};
use carla::client::{Client, World};
use pool::ServerLease;
static LEASE: LazyLock<ServerLease> = LazyLock::new(ServerLease::acquire);
static CLIENT: LazyLock<Client> = LazyLock::new(|| {
let port = LEASE.port();
let mut client =
Client::connect("127.0.0.1", port, None).expect("CARLA server must be running");
client
.set_timeout(Duration::from_secs(30))
.expect("Failed to set timeout");
client
});
pub fn client() -> &'static Client {
&CLIENT
}
pub fn world() -> World {
CLIENT.world().expect("Failed to get world")
}