Skip to main content

LeanWorkerSession

Struct LeanWorkerSession 

Source
pub struct LeanWorkerSession<'worker> { /* private fields */ }
Expand description

Narrow host-session adapter over a live LeanWorker.

Dropping this value does not stop the worker. If a request is cancelled while in flight, the supervisor cycles the child process and this session is invalidated; open a fresh session before issuing more host requests.

Implementations§

Source§

impl LeanWorkerSession<'_>

Source

pub fn request_timeout(&self) -> Duration

Return the timeout used for subsequent requests on this session.

Source

pub fn set_request_timeout(&mut self, timeout: Duration)

Change the timeout for subsequent requests on this session.

A timeout is parent-enforced. If it fires, the supervisor kills and replaces the child process and invalidates this session.

Source

pub fn elaborate( &mut self, source: &str, options: &LeanWorkerElabOptions, cancellation: Option<&LeanWorkerCancellationToken>, progress: Option<&dyn LeanWorkerProgressSink>, ) -> Result<LeanWorkerElabResult, LeanWorkerError>

Elaborate one term and return only process-safe success/diagnostic data.

§Errors

Returns LeanWorkerError if the worker is dead, the child reports a host error, cancellation is observed, a progress sink panics, or protocol communication fails.

Source

pub fn kernel_check( &mut self, source: &str, options: &LeanWorkerElabOptions, cancellation: Option<&LeanWorkerCancellationToken>, progress: Option<&dyn LeanWorkerProgressSink>, ) -> Result<LeanWorkerKernelResult, LeanWorkerError>

Kernel-check one declaration and return only process-safe status/diagnostics.

§Errors

Returns LeanWorkerError if the worker is dead, the child reports a host error, cancellation is observed, a progress sink panics, or protocol communication fails.

Source

pub fn declaration_kinds( &mut self, names: &[&str], cancellation: Option<&LeanWorkerCancellationToken>, progress: Option<&dyn LeanWorkerProgressSink>, ) -> Result<Vec<String>, LeanWorkerError>

Query declaration kinds in bulk.

§Errors

Returns LeanWorkerError if the worker is dead, the child reports a host error, cancellation is observed, a progress sink panics, or protocol communication fails.

Source

pub fn declaration_names( &mut self, names: &[&str], cancellation: Option<&LeanWorkerCancellationToken>, progress: Option<&dyn LeanWorkerProgressSink>, ) -> Result<Vec<String>, LeanWorkerError>

Render declaration names in bulk.

§Errors

Returns LeanWorkerError if the worker is dead, the child reports a host error, cancellation is observed, a progress sink panics, or protocol communication fails.

Source

pub fn run_data_stream( &mut self, export: &str, request: &Value, rows: &dyn LeanWorkerDataSink, diagnostics: Option<&dyn LeanWorkerDiagnosticSink>, cancellation: Option<&LeanWorkerCancellationToken>, progress: Option<&dyn LeanWorkerProgressSink>, ) -> Result<LeanWorkerStreamSummary, LeanWorkerError>

Run a downstream streaming export and deliver JSON rows to rows.

The Lean export must have ABI String -> USize -> USize -> IO UInt8. The child supplies the callback handle and trampoline; the parent only sees validated LeanWorkerDataRow values.

§Errors

Returns LeanWorkerError if the worker is dead, the child reports a host or stream error, cancellation is observed, a sink panics, or protocol communication fails. In-flight cancellation cycles the child and invalidates this session.

Source

pub fn run_json_command<Req, Resp>( &mut self, command: &LeanWorkerJsonCommand<Req, Resp>, request: &Req, cancellation: Option<&LeanWorkerCancellationToken>, progress: Option<&dyn LeanWorkerProgressSink>, ) -> Result<Resp, LeanWorkerError>
where Req: Serialize, Resp: DeserializeOwned,

Run a typed non-streaming downstream JSON command.

The Lean export must have ABI String -> IO String. The request is serialized from Req; the returned JSON string is decoded into Resp. Use this for commands that return one terminal JSON value and no rows.

§Errors

Returns LeanWorkerError if request encoding fails, the worker is dead, the session was invalidated, the export is missing, response decoding fails, cancellation or timeout is observed, a progress sink panics, or protocol communication fails.

Source

pub fn run_streaming_command<Req, Row, Summary>( &mut self, command: &LeanWorkerStreamingCommand<Req, Row, Summary>, request: &Req, rows: &dyn LeanWorkerTypedDataSink<Row>, diagnostics: Option<&dyn LeanWorkerDiagnosticSink>, cancellation: Option<&LeanWorkerCancellationToken>, progress: Option<&dyn LeanWorkerProgressSink>, ) -> Result<LeanWorkerTypedStreamSummary<Summary>, LeanWorkerError>
where Req: Serialize, Row: DeserializeOwned, Summary: DeserializeOwned,

Run a typed downstream streaming command.

The Lean export must have ABI String -> USize -> USize -> IO UInt8. The request is serialized from Req; each row payload is decoded into Row; terminal metadata is decoded into Summary when present. Raw-row access remains available through run_data_stream.

§Errors

Returns LeanWorkerError if request encoding fails, row or summary decoding fails, the worker is dead, the session was invalidated, the export fails, cancellation or timeout is observed, a sink panics, or protocol communication fails. Row decode errors include the stream and sequence that identified the bad payload.

Source

pub fn capability_metadata( &mut self, export: &str, request: &Value, cancellation: Option<&LeanWorkerCancellationToken>, progress: Option<&dyn LeanWorkerProgressSink>, ) -> Result<LeanWorkerCapabilityMetadata, LeanWorkerError>

Query generic metadata from a downstream capability export.

The Lean export must have ABI String -> IO String. The request and response strings are JSON, but callers receive a typed metadata envelope rather than private protocol frames.

§Errors

Returns LeanWorkerError if the worker is dead, the session was invalidated, the export is missing, request or response JSON is malformed, cancellation or timeout is observed, a progress sink panics, or protocol communication fails.

Source

pub fn capability_doctor( &mut self, export: &str, request: &Value, cancellation: Option<&LeanWorkerCancellationToken>, progress: Option<&dyn LeanWorkerProgressSink>, ) -> Result<LeanWorkerDoctorReport, LeanWorkerError>

Run a generic doctor check from a downstream capability export.

The Lean export must have ABI String -> IO String. Doctor diagnostics are capability-layer facts; data rows remain reserved for downstream streaming payloads.

§Errors

Returns LeanWorkerError if the worker is dead, the session was invalidated, the export is missing, request or response JSON is malformed, cancellation or timeout is observed, a progress sink panics, or protocol communication fails.

Auto Trait Implementations§

§

impl<'worker> Freeze for LeanWorkerSession<'worker>

§

impl<'worker> RefUnwindSafe for LeanWorkerSession<'worker>

§

impl<'worker> Send for LeanWorkerSession<'worker>

§

impl<'worker> Sync for LeanWorkerSession<'worker>

§

impl<'worker> Unpin for LeanWorkerSession<'worker>

§

impl<'worker> UnsafeUnpin for LeanWorkerSession<'worker>

§

impl<'worker> !UnwindSafe for LeanWorkerSession<'worker>

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

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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