Skip to main content

Part

Struct Part 

Source
pub struct Part {
    pub kind: PartKind,
    pub thought: Option<bool>,
    pub thought_signature: Option<Vec<u8>>,
    pub media_resolution: Option<PartMediaResolution>,
    pub video_metadata: Option<VideoMetadata>,
}
Expand description

内容部分。

Fields§

§kind: PartKind

具体内容变体。

§thought: Option<bool>

是否为思考内容。

§thought_signature: Option<Vec<u8>>

思考签名(base64 编码)。

§media_resolution: Option<PartMediaResolution>

媒体分辨率设置(按 part)。

§video_metadata: Option<VideoMetadata>

视频元数据。

Implementations§

Source§

impl Part

Source

pub fn text(text: impl Into<String>) -> Self

创建文本 Part。

Source

pub fn inline_data(data: Vec<u8>, mime_type: impl Into<String>) -> Self

创建内联二进制数据 Part。

Source

pub fn file_data( file_uri: impl Into<String>, mime_type: impl Into<String>, ) -> Self

创建文件 URI Part。

Source

pub const fn function_call(function_call: FunctionCall) -> Self

创建函数调用 Part。

Source

pub const fn function_response(function_response: FunctionResponse) -> Self

创建函数响应 Part。

Source

pub fn executable_code(code: impl Into<String>, language: Language) -> Self

创建可执行代码 Part。

Source

pub fn code_execution_result( outcome: Outcome, output: impl Into<String>, ) -> Self

创建代码执行结果 Part。

Source

pub const fn with_thought(self, thought: bool) -> Self

设置是否为思考内容。

Source

pub fn with_thought_signature(self, signature: Vec<u8>) -> Self

设置 thought signature。

Source

pub const fn with_media_resolution( self, resolution: PartMediaResolution, ) -> Self

设置媒体分辨率。

Source

pub fn with_video_metadata(self, metadata: VideoMetadata) -> Self

设置视频元数据。

Source

pub const fn text_value(&self) -> Option<&str>

获取文本内容(仅当为 Text Part)。

Source

pub const fn function_call_ref(&self) -> Option<&FunctionCall>

获取函数调用引用(仅当为 FunctionCall Part)。

Trait Implementations§

Source§

impl Clone for Part

Source§

fn clone(&self) -> Part

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Part

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Part

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Part

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Part

§

impl RefUnwindSafe for Part

§

impl Send for Part

§

impl Sync for Part

§

impl Unpin for Part

§

impl UnsafeUnpin for Part

§

impl UnwindSafe for Part

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,