Skip to main content

Session

Struct Session 

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

One resolved execution context: a named profile and the gateway client built from its POST-OVERLAY state. Construct through the three constructors — never by struct literal (the fields are the resolved choreography’s output, not inputs).

Manual Debug (no derive): the client isn’t Debug and must never be rendered credential-side — the profile NAME is the only safe field (the redaction discipline, CORE-02).

Implementations§

Source§

impl Session

Source

pub fn resolve(profile_flag: Option<&str>) -> Result<Self, CoreError>

Resolve through config: REQUIRED credential mode. Loads config (IGNITION_CLI_CONFIG first, platform path second), applies the env overlay scoped to the would-be selection, resolves the selection, then walks the LOCKED secret chain with NO degradation — a missing secret is CoreError::SecretUnavailable (exit 3), correct for authed reads. Replaces main.rs’s resolve_gateway_api (and named_profile_client: per-side resolution is just resolve(Some(name))).

Source

pub fn resolve_loaded( config: &mut Config, profile_flag: Option<&str>, ) -> Result<(Self, Profile), CoreError>

Resolve through a config the CALLER already loaded — the caller owns the load policy, the seam keeps everything downstream (overlay scoped to the selection → selection → LOCKED secret chain → REQUIRED-credential construction). This is the cockpit’s entry point: the TUI loads with config::load_for_tui, whose NEW-surface degradation contract (a schema typo warns and defaults instead of killing startup) must apply BEFORE the seam runs, while selection/auth failures stay fatal. Returns the session AND the selected POST-OVERLAY profile — the url string and cadence fields consumers like the cockpit display, which a Session deliberately doesn’t re-expose.

Source

pub fn resolve_side(config: &mut Config, name: &str) -> Result<Self, CoreError>

Resolve ONE NAMED side of a multi-profile command through a config the CALLER already loaded — the project diff/sync shape. Verbatim port of main.rs’s named_profile_client: the selection runs against the caller’s config with NO env overlay applied (side B carries its own URL even while IGNITION_URL overlays the envelope’s active profile — the contract the diff/sync goldens pin), then the LOCKED chain (required) and the client construction. The caller’s name rides the secret resolution verbatim, and the impossible empty-selection arm stays CoreError::Internal exactly as the original wrote it.

Source

pub fn resolve_degraded(profile_flag: Option<&str>) -> Result<Self, CoreError>

Resolve through config with the credential DEGRADED to None when the secret chain exhausts: version must not demand a secret (gateway-info answers), the wait commands must keep polling while auth is broken, the doctor diagnoses absent auth for a living. Every OTHER credential error propagates (the resolve_secret_opt behavior behind main.rs:431/760 and resolve_headerless_api). Selection errors are NOT degraded: no target is NoActiveProfile, as today.

Source

pub fn for_url( url: Url, credential: Option<Credential>, ssl_verify: bool, ) -> Result<Self, CoreError>

Headerless-BY-CONSTRUCTION client for the rig family: a caller- derived gateway URL (never a profile’s), an explicit optional credential, and the caller’s ssl_verify (rig probes use false — localhost probes against self-signed rig https are the norm). No config is read and no secret is resolved. Replaces main.rs’s rig_gateway_client + the TUI’s rig_client_with (the URL DERIVATION stays at the call sites; only the ReqwestGatewayApi construction moves behind this constructor — no second client construction anywhere).

Rig sessions carry NO profile: Self::profile_name returns the empty string (callers translate to None where the output model wants a profile echo).

Source

pub fn profile_name(&self) -> &str

The resolved profile’s name — empty for Self::for_url rig sessions (no profile exists).

Source

pub fn profile_url(&self) -> &Url

The resolved profile’s configured gateway URL — the POST-OVERLAY value (flag > IGNITION_URL env > profile), i.e. exactly what the session’s client targets. Doctor’s url check re-parses this raw value: the honest diagnosis must describe the URL the client ACTUALLY connects to, overlay included. For Self::for_url rig sessions this is the caller-derived rig URL.

Source

pub fn credential_present(&self) -> bool

Whether a credential resolved into this session’s client — the doctor’s credential_present flag (a MISSING credential is a different diagnosis than an UNRECOGNIZED one; the degraded chain decides, this accessor reports, and the secret itself never crosses the seam). Always true for Self::resolve; the caller’s Some-ness for Self::for_url.

Source

pub fn api(&self) -> &ReqwestGatewayApi

The gateway client, borrowed.

Source

pub fn api_handle(&self) -> Arc<ReqwestGatewayApi>

The gateway client as an owned Arc handle — the TUI’s workers/ClientHandle shape, without a second construction.

Methods from Deref<Target = ReqwestGatewayApi>§

Source

pub async fn send_and_classify_for_api( &self, request: RequestBuilder, url: &Url, ) -> Result<Response, CoreError>

The api-call-scoped pipeline entry (09-01): identical transport-error → Network mapping, then [classify] with api_call = true so an unclassified gateway 4xx maps to GatewayClientError (exit 2, verbatim capped body) instead of Internal. Public because ign api call’s action layer (09-03) is the production consumer and the contract tests (tests/api_classify_contract.rs) pin the full exit partition through it — nothing in the curated pipeline switches to it.

Trait Implementations§

Source§

impl Debug for Session

Source§

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

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

impl Deref for Session

Feeds every existing free-fn action over &GatewayApi unchanged: version(&*session, …) and friends work exactly as they did against a bare ReqwestGatewayApi.

Source§

type Target = ReqwestGatewayApi

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more