pub struct TextOutputSchema { /* private fields */ }Expand description
Schema for plain text output.
This schema validates text output with optional constraints:
- Pattern matching via regex
- Minimum/maximum length
- Trim whitespace
§Example
use serdes_ai_output::TextOutputSchema;
let schema = TextOutputSchema::new()
.with_min_length(10)
.with_max_length(1000)
.trim();Implementations§
Source§impl TextOutputSchema
impl TextOutputSchema
Sourcepub fn new() -> TextOutputSchema
pub fn new() -> TextOutputSchema
Create a new text output schema with no constraints.
Sourcepub fn with_pattern(self, pattern: &str) -> Result<TextOutputSchema, Error>
pub fn with_pattern(self, pattern: &str) -> Result<TextOutputSchema, Error>
Sourcepub fn with_min_length(self, len: usize) -> TextOutputSchema
pub fn with_min_length(self, len: usize) -> TextOutputSchema
Set the minimum length constraint.
Sourcepub fn with_max_length(self, len: usize) -> TextOutputSchema
pub fn with_max_length(self, len: usize) -> TextOutputSchema
Set the maximum length constraint.
Sourcepub fn trim(self) -> TextOutputSchema
pub fn trim(self) -> TextOutputSchema
Enable whitespace trimming.
Trait Implementations§
Source§impl Clone for TextOutputSchema
impl Clone for TextOutputSchema
Source§fn clone(&self) -> TextOutputSchema
fn clone(&self) -> TextOutputSchema
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TextOutputSchema
impl Debug for TextOutputSchema
Source§impl Default for TextOutputSchema
impl Default for TextOutputSchema
Source§fn default() -> TextOutputSchema
fn default() -> TextOutputSchema
Returns the “default value” for a type. Read more
Source§impl IntoOutputSpec<String> for TextOutputSchema
impl IntoOutputSpec<String> for TextOutputSchema
Source§fn into_output_spec(self) -> OutputSpec<String>
fn into_output_spec(self) -> OutputSpec<String>
Convert into an output spec.
Source§impl OutputSchema<String> for TextOutputSchema
impl OutputSchema<String> for TextOutputSchema
Source§fn mode(&self) -> OutputMode
fn mode(&self) -> OutputMode
The preferred output mode for this schema.
Source§fn parse_text(&self, text: &str) -> Result<String, OutputParseError>
fn parse_text(&self, text: &str) -> Result<String, OutputParseError>
Parse output from text.
Source§fn parse_tool_call(
&self,
_name: &str,
args: &Value,
) -> Result<String, OutputParseError>
fn parse_tool_call( &self, _name: &str, args: &Value, ) -> Result<String, OutputParseError>
Parse output from a tool call.
Source§fn parse_native(&self, value: &Value) -> Result<String, OutputParseError>
fn parse_native(&self, value: &Value) -> Result<String, OutputParseError>
Parse output from native structured response.
Source§fn tool_definitions(&self) -> Vec<ToolDefinition>
fn tool_definitions(&self) -> Vec<ToolDefinition>
Get tool definitions if using tool mode. Read more
Source§fn json_schema(&self) -> Option<ObjectJsonSchema>
fn json_schema(&self) -> Option<ObjectJsonSchema>
Get JSON schema for native/prompted mode. Read more
Source§fn supports_mode(&self, mode: OutputMode) -> bool
fn supports_mode(&self, mode: OutputMode) -> bool
Whether this schema supports a given output mode.
Auto Trait Implementations§
impl Freeze for TextOutputSchema
impl RefUnwindSafe for TextOutputSchema
impl Send for TextOutputSchema
impl Sync for TextOutputSchema
impl Unpin for TextOutputSchema
impl UnwindSafe for TextOutputSchema
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