Skip to main content

Crate simple_agents_macros

Crate simple_agents_macros 

Source
Expand description

Procedural macros for SimpleAgents.

This crate provides derive macros for automatic schema generation and partial type support for streaming responses.

§Macros

  • PartialType - Generates a partial version of a type with all fields as Option<T>

§Example

use simple_agents_macros::PartialType;
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, PartialType, Serialize, Deserialize)]
pub struct User {
    pub id: u64,
    pub name: String,
    pub email: String,
    pub age: u32,
}

let partial = PartialUser {
    id: Some(1),
    name: Some("Ada".to_string()),
    email: Some("ada@example.com".to_string()),
    age: Some(42),
};
let user = User::from_partial(partial).unwrap();
assert_eq!(user.name, "Ada");

Derive Macros§

PartialType
Derives a partial type for streaming support.