Skip to main content

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.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl ToAttachments for PathBuf

Source§

impl ToAttachments for Vec<u8>

Source§

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

Source§

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

Implementors§