pub struct ModelRegistry { /* private fields */ }Expand description
The multi-model registry.
Manages a collection of ModelEndpoint instances and supports alias
resolution so that clients can refer to models by friendly names.
Implementations§
Source§impl ModelRegistry
impl ModelRegistry
Sourcepub fn register(&mut self, endpoint: ModelEndpoint)
pub fn register(&mut self, endpoint: ModelEndpoint)
Register a model endpoint.
If the endpoint has is_default set, it becomes the default model.
Replaces any existing endpoint with the same ID.
Sourcepub fn unregister(&mut self, id: &ModelId) -> Option<ModelEndpoint>
pub fn unregister(&mut self, id: &ModelId) -> Option<ModelEndpoint>
Remove an endpoint from the registry.
Also clears the default-model pointer if it pointed to the removed endpoint, and removes any aliases that targeted this ID.
Sourcepub fn add_alias(&mut self, alias: impl Into<String>, target: ModelId)
pub fn add_alias(&mut self, alias: impl Into<String>, target: ModelId)
Add an alias: e.g. "gpt-4" maps to ModelId("bonsai-8b").
Sourcepub fn resolve(&self, id_or_alias: &str) -> Option<&ModelEndpoint>
pub fn resolve(&self, id_or_alias: &str) -> Option<&ModelEndpoint>
Resolve a model identifier (checks ID first, then aliases).
Returns None if neither a direct ID nor an alias matches.
Sourcepub fn default_endpoint(&self) -> Option<&ModelEndpoint>
pub fn default_endpoint(&self) -> Option<&ModelEndpoint>
Get the default model endpoint.
Sourcepub fn available_endpoints(&self) -> Vec<&ModelEndpoint>
pub fn available_endpoints(&self) -> Vec<&ModelEndpoint>
List all available (Ready) endpoints.
Sourcepub fn all_endpoints(&self) -> Vec<&ModelEndpoint>
pub fn all_endpoints(&self) -> Vec<&ModelEndpoint>
List all registered endpoints (including non-ready ones).
Sourcepub fn set_status(&mut self, id: &ModelId, status: EndpointStatus) -> bool
pub fn set_status(&mut self, id: &ModelId, status: EndpointStatus) -> bool
Update an endpoint’s status.
Returns true if the endpoint was found and updated.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ModelRegistry
impl RefUnwindSafe for ModelRegistry
impl Send for ModelRegistry
impl Sync for ModelRegistry
impl Unpin for ModelRegistry
impl UnsafeUnpin for ModelRegistry
impl UnwindSafe for ModelRegistry
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more