pub struct Session {
pub provider: Option<String>,
pub model: Option<String>,
}Expand description
The last-active selections read from the [session] table.
Fields§
§provider: Option<String>Last [[backends]] name chosen via /backends <name>.
model: Option<String>Last model override chosen via /model <name> (the NEWT_DGX_MODEL axis).
Implementations§
Source§impl Session
impl Session
Sourcepub fn from_doc(doc: &Table) -> Self
pub fn from_doc(doc: &Table) -> Self
Extract [session] selections from a parsed settings document. Tolerant
of a missing table, missing keys, non-string values, and empty strings
(all read as None) — a malformed file must never break startup.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
True when nothing is recorded (skip the whole restore/write dance).
Sourcepub fn restore(
&self,
current_provider: Option<&str>,
model_pinned: bool,
known_backend: impl Fn(&str) -> bool,
) -> Restore
pub fn restore( &self, current_provider: Option<&str>, model_pinned: bool, known_backend: impl Fn(&str) -> bool, ) -> Restore
Decide what to restore. current_provider is the value NEWT_PROVIDER
already holds (an explicit env var or a --loadout’s provider) — None
if unset; a pinned provider is left untouched. model_pinned is whether
NEWT_DGX_MODEL is already set. known_backend guards the recorded
provider so a stale name (backend since removed from config) is dropped
rather than producing a dangling pin. Pure — the caller owns the env and
config lookups, keeping this fully unit-testable.
A recorded model belongs to the provider it was chosen under
(self.provider), so it is restored only when that provider is the one
that will actually be active. This keeps a model picked for one backend
from bleeding onto a different backend selected by env or a --loadout
— matching the in-app rule that picking a provider clears the model
override. (When both are None the model was chosen on the default
backend, which is also what’s active, so a bare /model choice still
sticks.)
Trait Implementations§
impl Eq for Session
impl StructuralPartialEq for Session
Auto Trait Implementations§
impl Freeze for Session
impl RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnsafeUnpin for Session
impl UnwindSafe for Session
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
impl<T> ErasedDestructor for Twhere
T: 'static,
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