Skip to main content

ModelRef

Struct ModelRef 

Source
pub struct ModelRef<D: ?Sized>(/* private fields */);
Expand description

A reference to a model: either a resolved instance or a provider:model id that the application layer resolves through its registry.

D is the object-safe trait object type (dyn DynLanguageModel, …). Provider implementations always return resolved references; the id form exists so that entry points can accept impl Into<LanguageModelRef> for both model instances and strings.

Implementations§

Source§

impl<D: ?Sized> ModelRef<D>

Source

pub fn from_arc(model: Arc<D>) -> Self

Wraps a resolved model.

Source

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

Creates an unresolved reference by id (for example openai:gpt-5).

Source

pub fn model(&self) -> Option<&Arc<D>>

Returns the model when the reference is resolved.

Source

pub fn unresolved_id(&self) -> Option<&str>

Returns the id when the reference is unresolved.

Source

pub fn is_resolved(&self) -> bool

Returns true when the reference holds a model instance.

Source

pub fn into_model(self) -> Result<Arc<D>, String>

Unwraps the model, or returns the unresolved id as the error.

§Errors

Returns the id when the reference was created with ModelRef::from_id.

Trait Implementations§

Source§

impl<D: ?Sized> Clone for ModelRef<D>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<D: ?Sized> Debug for ModelRef<D>

Source§

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

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

impl<D: ?Sized> From<&str> for ModelRef<D>

Source§

fn from(id: &str) -> Self

Converts to this type from the input type.
Source§

impl<D: ?Sized> From<Arc<D>> for ModelRef<D>

Source§

fn from(model: Arc<D>) -> Self

Converts to this type from the input type.
Source§

impl<D: ?Sized> From<String> for ModelRef<D>

Source§

fn from(id: String) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<D> Freeze for ModelRef<D>
where Inner<D>: Freeze, D: ?Sized,

§

impl<D> RefUnwindSafe for ModelRef<D>
where Inner<D>: RefUnwindSafe, D: ?Sized,

§

impl<D> Send for ModelRef<D>
where Inner<D>: Send, D: ?Sized,

§

impl<D> Sync for ModelRef<D>
where Inner<D>: Sync, D: ?Sized,

§

impl<D> Unpin for ModelRef<D>
where Inner<D>: Unpin, D: ?Sized,

§

impl<D> UnsafeUnpin for ModelRef<D>
where Inner<D>: UnsafeUnpin, D: ?Sized,

§

impl<D> UnwindSafe for ModelRef<D>
where Inner<D>: UnwindSafe, D: ?Sized,

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 = !

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.