ToAttachments

Trait ToAttachments 

Source
pub trait ToAttachments {
    // Required method
    fn to_attachments(&self) -> Vec<(String, Attachment)>;
}
Expand description

Trait for types that can produce named attachments.

This trait is typically derived using #[derive(ToAttachments)]. Types implementing this trait can be used as agent outputs that produce file-based data that can be consumed by subsequent agents in a workflow.

§Examples

use llm_toolkit::attachment::{Attachment, ToAttachments};
use std::path::PathBuf;

// Manual implementation
struct MyOutput {
    data: Vec<u8>,
}

impl ToAttachments for MyOutput {
    fn to_attachments(&self) -> Vec<(String, Attachment)> {
        vec![("data".to_string(), Attachment::in_memory(self.data.clone()))]
    }
}

let output = MyOutput { data: vec![1, 2, 3] };
let attachments = output.to_attachments();
assert_eq!(attachments.len(), 1);
assert_eq!(attachments[0].0, "data");

Required Methods§

Source

fn to_attachments(&self) -> Vec<(String, Attachment)>

Converts this type into a list of named attachments.

Returns Vec<(key, Attachment)> where key identifies the attachment. The key is used by the orchestrator to reference this attachment in subsequent steps.

Implementations on Foreign Types§

Source§

impl ToAttachments for Vec<u8>

Source§

impl ToAttachments for PathBuf

Source§

impl<T: ToAttachments> ToAttachments for Option<T>

Source§

impl<T: ToAttachments> ToAttachments for Vec<T>

Implementors§