pub struct ModelSet { /* private fields */ }Expand description
Models a host offers, each id once, in the order the host lists them.
Implementations§
Source§impl ModelSet
impl ModelSet
Sourcepub fn new(build: BuildInfo) -> Self
pub fn new(build: BuildInfo) -> Self
Returns an empty set that records build as the build of every entry inserted without one.
Sourcepub fn insert(&mut self, entry: ModelEntry) -> Result<&mut Self, ModelSetError>
pub fn insert(&mut self, entry: ModelEntry) -> Result<&mut Self, ModelSetError>
Adds entry. An entry whose source records no build yet receives the set’s build, and any other entry keeps
the build it records.
Note that an entry registered from a type in a third-party crate also receives the set’s build. Its source’s
type path still refers to the real crate. A model library therefore exports a set built from its own
build_info!, and its entries keep its name and version.
§Errors
Returns ModelSetError::DuplicateId for an id the set holds, and ModelSetError::InvalidId for an id
outside the grammar. The set is unchanged on an error.
Sourcepub fn extend(&mut self, other: Self) -> Result<&mut Self, ModelSetError>
pub fn extend(&mut self, other: Self) -> Result<&mut Self, ModelSetError>
Adds every entry of other, each keeping its own source.
§Errors
Returns ModelSetError::DuplicateId for an id both sets hold. Checks every id before it adds any, and
leaves the set unchanged on an error.
Sourcepub fn get(&self, id: &str) -> Option<&ModelEntry>
pub fn get(&self, id: &str) -> Option<&ModelEntry>
Returns entry id, whether or not a host can run it.
Sourcepub fn lookup(
&self,
id: &str,
gpu: Option<&GpuContext>,
) -> Result<&ModelEntry, ModelLookupError>
pub fn lookup( &self, id: &str, gpu: Option<&GpuContext>, ) -> Result<&ModelEntry, ModelLookupError>
Returns entry id, or the reason a host with gpu cannot run it.
§Errors
Returns ModelLookupError::NotInSet for an id missing from the set, and
ModelLookupError::NeedsGpu for a GPU model when gpu is None.
Sourcepub fn runnable<'a>(
&'a self,
gpu: Option<&GpuContext>,
) -> impl Iterator<Item = &'a ModelEntry> + use<'a>
pub fn runnable<'a>( &'a self, gpu: Option<&GpuContext>, ) -> impl Iterator<Item = &'a ModelEntry> + use<'a>
Returns the entries a host with gpu can run, in the set’s order. A GPU model runs only with a device.
Sourcepub fn iter(&self) -> ModelSetIter<'_> ⓘ
pub fn iter(&self) -> ModelSetIter<'_> ⓘ
Returns an iterator over the entries, in the set’s order.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for ModelSet
impl !UnwindSafe for ModelSet
impl Freeze for ModelSet
impl Send for ModelSet
impl Sync for ModelSet
impl Unpin for ModelSet
impl UnsafeUnpin for ModelSet
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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