use super::common::get_volume;
use crate::{
DriverCallback, DriverCategory, DriverContext, DriverError, DriverResult,
types::{Driver, DriverParameter},
};
use serde_json::{Value, json};
use std::collections::HashMap;
use tracing::{debug, info};
#[derive(Debug)]
pub struct AudioControlVolumeGetDriver;
#[async_trait::async_trait]
impl Driver for AudioControlVolumeGetDriver {
fn name(&self) -> &str {
"audio_control_volume_get"
}
fn description(&self) -> &str {
"Get the current system volume level"
}
fn usage_hint(&self) -> &str {
"Use this skill to query the current audio volume (0-100)."
}
fn parameters(&self) -> Vec<DriverParameter> {
return vec![];
}
fn example_call(&self) -> DriverResult<Value> {
Ok(json!({
"action": "audio_control_volume_get"
}))
}
fn example_output(&self) -> String {
"Current volume: 65%".to_string()
}
fn category(&self) -> DriverCategory {
DriverCategory::Audio
}
async fn execute(
&self,
_parameters: &HashMap<String, Value>,
_callback: Option<&dyn DriverCallback>,
_context: Option<&DriverContext>,
) -> DriverResult<String> {
debug!("Executing audio_control_volume_get driver");
let volume = get_volume().map_err(|e| DriverError::execution(format!("Failed to get volume: {}", e)))?;
info!("Current volume: {}%", volume);
Ok(format!("Current volume: {}%", volume))
}
}