pub struct Field {
pub name: String,
pub schema: Schema,
pub required: bool,
pub aliases: Vec<String>,
pub default: Option<Value>,
pub description: Option<String>,
pub stream_annotation: StreamAnnotation,
}Expand description
Field definition in an object schema.
Fields§
§name: StringField name as it appears in the schema
schema: SchemaExpected type for this field
required: boolWhether this field is required (true) or optional (false)
aliases: Vec<String>Alternative names this field might have (aliases)
default: Option<Value>Default value if field is missing (JSON string representation)
description: Option<String>Description of the field (for documentation)
stream_annotation: StreamAnnotationStreaming annotation (controls emission timing)
Implementations§
Source§impl Field
impl Field
Sourcepub fn with_alias(self, alias: impl Into<String>) -> Self
pub fn with_alias(self, alias: impl Into<String>) -> Self
Add an alias to this field.
Sourcepub fn with_default(self, default: Value) -> Self
pub fn with_default(self, default: Value) -> Self
Add a default value for this field.
Sourcepub fn with_description(self, description: impl Into<String>) -> Self
pub fn with_description(self, description: impl Into<String>) -> Self
Add a description to this field.
Sourcepub fn with_stream_annotation(self, annotation: StreamAnnotation) -> Self
pub fn with_stream_annotation(self, annotation: StreamAnnotation) -> Self
Set the streaming annotation for this field.
§Examples
use simple_agents_healing::schema::{Field, Schema, StreamAnnotation};
// Don't emit until non-null
let id_field = Field::required("id", Schema::Int)
.with_stream_annotation(StreamAnnotation::NotNull);
// Only emit when complete
let status_field = Field::required("status", Schema::String)
.with_stream_annotation(StreamAnnotation::Done);Trait Implementations§
Source§impl<'de> Deserialize<'de> for Field
impl<'de> Deserialize<'de> for Field
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Field
Auto Trait Implementations§
impl Freeze for Field
impl RefUnwindSafe for Field
impl Send for Field
impl Sync for Field
impl Unpin for Field
impl UnsafeUnpin for Field
impl UnwindSafe for Field
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more