use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct FunctionShellCallOutputContent {
#[serde(rename = "stdout")]
pub stdout: String,
#[serde(rename = "stderr")]
pub stderr: String,
#[serde(rename = "outcome")]
pub outcome: Box<models::ShellCallOutcome>,
#[serde(rename = "created_by", skip_serializing_if = "Option::is_none")]
pub created_by: Option<String>,
}
impl FunctionShellCallOutputContent {
pub fn new(
stdout: String,
stderr: String,
outcome: models::ShellCallOutcome,
) -> FunctionShellCallOutputContent {
FunctionShellCallOutputContent {
stdout,
stderr,
outcome: Box::new(outcome),
created_by: None,
}
}
}
impl std::fmt::Display for FunctionShellCallOutputContent {
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),
}
}
}