Skip to main content

Model

Struct Model 

Source
pub struct Model { /* private fields */ }
Expand description

已加载的模型。

由 crate::Registry::load 创建,持有一个 C 句柄,并共享持有 C 注册表的所有权——Registry 释放后模型仍可继续使用。

Implementations§

Source§

impl Model

Source

pub fn metadata(&self) -> Result<ModelMetadata, Error>

模型元数据(family / variant / description / 候选配置与权重)。

§Errors

C ABI 调用失败或返回的 JSON 无法解析时返回对应 Error 变体。

Source

pub fn capabilities(&self) -> Result<Capabilities, Error>

模型能力集合。

§Errors

C ABI 调用失败或返回的 JSON 无法解析时返回对应 Error 变体。

Source

pub fn create_task_session( &self, task: TaskKind, mode: RunMode, backend: Backend, device: i32, threads: i32, session_options: Option<&str>, ) -> Result<Session, Error>

在模型上创建一次任务会话。

可从 metadata() / capabilities() 确认模型是否支持目标任务与模式。 返回的 Session 同样共享持有 C 注册表的所有权;会话创建后释放 Model(乃至 Registry)不影响其继续工作。

§Errors

参数含 NUL / 非 UTF-8 返回 Error::Nul 或 Error::NonUtf8Path; 底层无法创建会话返回 Error::NullHandle。

Trait Implementations§

Source§

impl Drop for Model

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Send for Model

Auto Trait Implementations§

§

impl !RefUnwindSafe for Model

§

impl !Sync for Model

§

impl !UnwindSafe for Model

§

impl Forget for Model

§

impl Freeze for Model

§

impl Unpin for Model

§

impl UnsafeUnpin for Model

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.