Silk

silk/native_diagnostics

Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, x86_64-unknown-linux-gnu.

Source-owned native failure reports with bounded optional context.

When to use

Use NativeDiagnostics.make to select the report writer and context capacity. Use NativeDiagnostics.observe to give one lazy computation ownership of that report state.

Details

Failure identity and origin remain available when optional storage is exhausted. Handled failures release their context for reuse. Report output uses the supplied writer's bounds.

Gotchas

This observer borrows the writer's descriptor. It does not close the descriptor or select a process exit code. Terminal failure observation returns policy 1, including when output fails. Fatal reports end in the compiler's trap.

Import as NativeDiagnostics with import silk.native_diagnostics { NativeDiagnostics }.

Public declarations: 1.

NativeDiagnostics

pub struct NativeDiagnostics

An owned native report writer with bounded optional failure context.

Associated function NativeDiagnostics.make

pub effect<'static> fn make(report: NativeReport, capacity: usize) -> NativeDiagnostics

Creates an independent report owner with space for at most capacity context nodes.

Details

Zero capacity allocates no context storage. Overflow or allocation refusal also disables optional context storage. The writer retains the descriptor and output limits supplied by the caller. Construction writes no output.

Gotchas

Failure identity and origin remain available without optional context. Frames and causes can be omitted when storage is exhausted.

Method NativeDiagnostics.observe

pub fn observe<'env, A, ?R>(self: NativeDiagnostics, body: once Effect<'env; A ? R>) -> once Effect<'env; A ? R>

Transfers this report owner into a lazy observation scope around body.

Details

Construction does not run body. Dropping the returned Effect releases the report state, including before the first run. Suspension retains the state. Completion and cancellation release it after protected cleanup. The body's success value and requirements are unchanged. The body must handle its typed failures.

Gotchas

Destroy a terminal failure payload before calling Intrinsic.observeUnhandled in its selected handler. Terminal observation returns policy 1 even when the writer cannot complete the report.

On this page