pub struct ModelStreamChunk(/* private fields */);Expand description
One exact, non-empty provider-normalized stream fragment.
Fragments preserve UTF-8 bytes without trimming or normalization. A JSON or tool-argument fragment need not be valid JSON by itself; the accumulator parses the exact concatenation only when its output item closes. Debug output reveals only the encoded length.
Implementations§
Source§impl ModelStreamChunk
impl ModelStreamChunk
Sourcepub fn new(value: impl Into<String>) -> Result<Self, ModelStreamChunkError>
pub fn new(value: impl Into<String>) -> Result<Self, ModelStreamChunkError>
Validates and retains an owned stream fragment.
§Errors
Returns ModelStreamChunkError for empty, oversized, control-bearing,
or Unicode-noncharacter input.
Sourcepub fn len_bytes(&self) -> usize
pub fn len_bytes(&self) -> usize
Returns the retained UTF-8 byte length without disclosing content.
Sourcepub fn into_string(self) -> String
pub fn into_string(self) -> String
Consumes the fragment and returns its allocation.
Trait Implementations§
Source§impl AsRef<str> for ModelStreamChunk
impl AsRef<str> for ModelStreamChunk
Source§impl Clone for ModelStreamChunk
impl Clone for ModelStreamChunk
Source§impl Debug for ModelStreamChunk
impl Debug for ModelStreamChunk
Source§impl<'de> Deserialize<'de> for ModelStreamChunk
impl<'de> Deserialize<'de> for ModelStreamChunk
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 Eq for ModelStreamChunk
Source§impl Hash for ModelStreamChunk
impl Hash for ModelStreamChunk
Source§impl JsonSchema for ModelStreamChunk
impl JsonSchema for ModelStreamChunk
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(_: &mut SchemaGenerator) -> Schema
fn json_schema(_: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreSource§impl Ord for ModelStreamChunk
impl Ord for ModelStreamChunk
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialEq for ModelStreamChunk
impl PartialEq for ModelStreamChunk
Source§impl PartialOrd for ModelStreamChunk
impl PartialOrd for ModelStreamChunk
Source§impl Serialize for ModelStreamChunk
impl Serialize for ModelStreamChunk
impl StructuralPartialEq for ModelStreamChunk
Auto Trait Implementations§
impl Forget for ModelStreamChunk
impl Freeze for ModelStreamChunk
impl Move for ModelStreamChunk
impl RefUnwindSafe for ModelStreamChunk
impl Send for ModelStreamChunk
impl Sync for ModelStreamChunk
impl Unpin for ModelStreamChunk
impl UnsafeUnpin for ModelStreamChunk
impl UnwindSafe for ModelStreamChunk
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