use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct FunctionShellAction {
#[serde(rename = "commands")]
pub commands: Vec<String>,
#[serde(rename = "timeout_ms", deserialize_with = "Option::deserialize")]
pub timeout_ms: Option<i32>,
#[serde(rename = "max_output_length", deserialize_with = "Option::deserialize")]
pub max_output_length: Option<i32>,
}
impl FunctionShellAction {
pub fn new(
commands: Vec<String>,
timeout_ms: Option<i32>,
max_output_length: Option<i32>,
) -> FunctionShellAction {
FunctionShellAction {
commands,
timeout_ms,
max_output_length,
}
}
}
impl std::fmt::Display for FunctionShellAction {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match serde_json::to_string(self) {
Ok(s) => write!(f, "{}", s),
Err(_) => Err(std::fmt::Error),
}
}
}