pub struct FilePart {
pub content: BinaryContent,
pub id: Option<String>,
pub provider_name: Option<String>,
pub provider_details: Option<Map<String, Value>>,
}Expand description
A file response from a model.
Represents file content generated by models, such as images from
image generation APIs. This is the Rust equivalent of pydantic-ai’s
FilePart type.
Fields§
§content: BinaryContentThe binary content of the file.
id: Option<String>Optional unique identifier for this part.
provider_name: Option<String>Provider name that generated this file.
provider_details: Option<Map<String, Value>>Provider-specific details/metadata.
Implementations§
Source§impl FilePart
impl FilePart
Sourcepub fn new(content: BinaryContent) -> FilePart
pub fn new(content: BinaryContent) -> FilePart
Create a new file part.
Sourcepub fn from_bytes(data: Vec<u8>, media_type: impl Into<String>) -> FilePart
pub fn from_bytes(data: Vec<u8>, media_type: impl Into<String>) -> FilePart
Create a new file part from raw data and media type.
Sourcepub fn with_provider_name(self, name: impl Into<String>) -> FilePart
pub fn with_provider_name(self, name: impl Into<String>) -> FilePart
Set the provider name.
Sourcepub fn with_provider_details(self, details: Map<String, Value>) -> FilePart
pub fn with_provider_details(self, details: Map<String, Value>) -> FilePart
Set provider-specific details.
Sourcepub fn has_content(&self) -> bool
pub fn has_content(&self) -> bool
Check if the file has content.
Sourcepub fn media_type(&self) -> &str
pub fn media_type(&self) -> &str
Get the media type of the file content.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for FilePart
impl<'de> Deserialize<'de> for FilePart
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<FilePart, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<FilePart, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<FilePart> for ModelResponsePart
impl From<FilePart> for ModelResponsePart
Source§fn from(p: FilePart) -> ModelResponsePart
fn from(p: FilePart) -> ModelResponsePart
Converts to this type from the input type.
Source§impl Serialize for FilePart
impl Serialize for FilePart
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for FilePart
Auto Trait Implementations§
impl Freeze for FilePart
impl RefUnwindSafe for FilePart
impl Send for FilePart
impl Sync for FilePart
impl Unpin for FilePart
impl UnwindSafe for FilePart
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