pub struct ItemType {
pub type_name: String,
pub description: Option<String>,
pub items: Option<Box<JsonItem>>,
}
Expand description
Represents a single property or item type within a JSON schema.
This structure defines the type and characteristics of individual properties in a JSON schema. It can represent simple types (string, number, boolean) or complex types (arrays, objects) with nested structures.
§Fields
type_name
- The JSON type of this item (e.g., “string”, “number”, “array”, “object”)description
- Optional human-readable description of the propertyitems
- For array types, defines the structure of array elements
§Supported Types
- “string”: Text values
- “number”: Numeric values (integers and floats)
- “boolean”: True/false values
- “array”: Lists of items with defined structure
- “object”: Complex nested objects
§Example
use openai_tools::structured_output::ItemType;
// Simple string property
let name_prop = ItemType::new(
"string".to_string(),
Some("The user's full name".to_string())
);
// Numeric property
let age_prop = ItemType::new(
"number".to_string(),
Some("Age in years".to_string())
);
Fields§
§type_name: String
§description: Option<String>
§items: Option<Box<JsonItem>>
Implementations§
Source§impl ItemType
impl ItemType
Sourcepub fn new(type_name: String, description: Option<String>) -> Self
pub fn new(type_name: String, description: Option<String>) -> Self
Creates a new ItemType
with the specified type and optional description.
§Arguments
type_name
- The JSON type name (e.g., “string”, “number”, “boolean”, “array”, “object”)description
- Optional description explaining the purpose of this property
§Returns
A new ItemType
instance with the specified type and description.
§Example
use openai_tools::structured_output::ItemType;
// Create a string property with description
let email = ItemType::new(
"string".to_string(),
Some("A valid email address".to_string())
);
// Create a number property without description
let count = ItemType::new("number".to_string(), None);
Sourcepub fn clone(&self) -> Self
pub fn clone(&self) -> Self
Creates a deep clone of this ItemType
instance.
This method performs a deep copy of all nested structures, including
any complex items
that may be present for array types.
§Returns
A new ItemType
instance that is an exact copy of this one.
§Note
This method is more explicit than the auto-derived Clone
trait
and ensures proper deep copying of nested Box
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ItemType
impl<'de> Deserialize<'de> for ItemType
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>,
Auto Trait Implementations§
impl Freeze for ItemType
impl RefUnwindSafe for ItemType
impl Send for ItemType
impl Sync for ItemType
impl Unpin for ItemType
impl UnwindSafe for ItemType
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more