1. CLI dialer
use telequick::TeleQuickClient;
use std::sync::Arc;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {{
let args: Vec<String> = std::env::args().collect();
let to = &args[1];
let trunk = args.get(2).map(String::as_str).unwrap_or("default");
let mut client = TeleQuickClient::new(
"quic://engine.telequick.dev:9090",
&std::env::var("TELEQUICK_LIB_PATH")?,
)?;
client.on_call_event = Some(Arc::new(|p| {{
eprintln!("event: {{}} bytes", p.len());
}}));
client.dial(to, trunk, false, 250, None).await?;
tokio::time::sleep(std::time::Duration::from_secs(60)).await;
Ok(())
}}
2. Edge orchestrator with shared client
A tower-style HTTP server that exposes/dial and /terminate endpoints,
backed by one long-lived TeleQuickClient.
use axum::{{routing::post, Json, Router, extract::State}};
use serde::Deserialize;
use std::sync::Arc;
use tokio::sync::Mutex;
use telequick::TeleQuickClient;
#[derive(Clone)]
struct AppState {{ client: Arc<Mutex<TeleQuickClient>> }}
#[derive(Deserialize)]
struct DialReq {{ to: String, trunk: String }}
async fn dial_handler(
State(s): State<AppState>,
Json(req): Json<DialReq>,
) -> &'static str {{
let mut c = s.client.lock().await;
c.dial(&req.to, &req.trunk, false, 250, None).await.ok();
"ok"
}}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {{
let client = TeleQuickClient::new(
"quic://engine.telequick.dev:9090",
"/usr/local/lib/telequick_core_ffi.so",
)?;
let state = AppState {{ client: Arc::new(Mutex::new(client)) }};
let app = Router::new()
.route("/dial", post(dial_handler))
.with_state(state);
let listener = tokio::net::TcpListener::bind("0.0.0.0:7000").await?;
axum::serve(listener, app).await?;
Ok(())
}}
3. Bulk dialer with structured events
FunnelCallEvent payloads into a parsing task via mpsc:
use std::sync::Arc;
use tokio::sync::mpsc;
use telequick::TeleQuickClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {{
let (tx, mut rx) = mpsc::unbounded_channel::<Vec<u8>>();
let mut client = TeleQuickClient::new(
"quic://engine.telequick.dev:9090",
"/usr/local/lib/telequick_core_ffi.so",
)?;
client.on_call_event = Some(Arc::new(move |payload| {{
let _ = tx.send(payload);
}}));
tokio::spawn(async move {{
while let Some(p) = rx.recv().await {{
// Decode the serde envelope here using your favorite reader,
// or call into the FFI's deserializer.
println!("evt {{}} bytes", p.len());
}}
}});
client.originate_bulk(
"https://files.example.com/numbers.csv",
"default",
20, // cps
"campaign-2026-04",
false,
250,
).await?;
tokio::time::sleep(std::time::Duration::from_secs(900)).await;
Ok(())
}}
4. AI bridge over native QUIC
Pumpon_audio_frame to an LLM realtime endpoint:
use std::sync::Arc;
use tokio_tungstenite::connect_async;
use futures_util::{{SinkExt, StreamExt}};
use telequick::TeleQuickClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {{
let mut client = TeleQuickClient::new(
"quic://engine.telequick.dev:9090",
"/usr/local/lib/telequick_core_ffi.so",
)?;
let (mut ws, _) = connect_async(
"wss://api.openai.com/v1/realtime?model=gpt-realtime"
).await?;
let (audio_tx, mut audio_rx) = tokio::sync::mpsc::unbounded_channel::<Vec<u8>>();
client.on_audio_frame = Some(Arc::new(move |p| {{ let _ = audio_tx.send(p); }}));
tokio::spawn(async move {{
while let Some(p) = audio_rx.recv().await {{
let b64 = base64::encode(&p);
let frame = format!(
r#"{{{{"type":"input_audio_buffer.append","audio":"{{}}"}}}}"#, b64
);
ws.send(frame.into()).await.ok();
}}
}});
client.dial("sip:+15551234567@…", "default", false, 250, None).await?;
tokio::time::sleep(std::time::Duration::from_secs(120)).await;
Ok(())
}}
5. Health check + reconnect loop
Treat the QUIC client as ephemeral — wrap it in a supervised task that restarts on error.use std::time::Duration;
use telequick::TeleQuickClient;
#[tokio::main]
async fn main() {{
loop {{
if let Err(e) = run_once().await {{
eprintln!("session ended: {{:?}}; restart in 2s", e);
tokio::time::sleep(Duration::from_secs(2)).await;
}}
}}
}}
async fn run_once() -> Result<(), Box<dyn std::error::Error>> {{
let mut client = TeleQuickClient::new(
"quic://engine.telequick.dev:9090",
"/usr/local/lib/telequick_core_ffi.so",
)?;
client.connect().await?;
// … your real work …
Ok(())
}}