Silk

silk/os_host_input

Native HostInput provider for the process command line, environment, and working directory.

When to use

Construct OsHostInput at a native application edge and provide it to portable code requiring HostInput. Tests can replace it with a deterministic provider and keep process state out of the program under test.

Details

The provider owns no persistent state. Each successful lookup copies the host value into independent Bytes, beginning with a bounded buffer and retrying once at the exact size the boundary reports. An absent argument or variable remains None; an unavailable working directory and contradictory host lengths become HostInputError.

Constructing the provider reads no host state. Portable code performs lookups after the application supplies &mut OsHostInput for the &mut HostInput requirement. Each owned result also requires an allocator.

Gotchas

Reachable OS host-input operations are native-only. Direct WebAssembly compilation rejects them instead of inventing process-global imports; evaluator execution requires an injected adapter.

Examples

Construct the native provider without reading process state

import silk.os_host_input as OsHostInput

pub fn main() -> i32 {
  let provider = OsHostInput.make()
  drop provider
  return 42
}

Import as OsHostInput with import silk.os_host_input.

Public declarations: 2.

OsHostInput

pub struct OsHostInput

A stateless native HostInput provider for process arguments, environment, and directory.

Details

The process owns the source values. Each successful byte lookup returns a new owned copy through the portable service.

make

pub fn make() -> OsHostInput

Creates a stateless provider for native process input.

When to use

Use this function at a native application edge. Provide the result as &mut HostInput to portable lookup operations in silk.host_input.

Details

Construction performs no lookup and cannot fail. Argument and environment absence remain ordinary None values when a later lookup runs.

Implementation HostInput for OsHostInput

impl HostInput for OsHostInput

Operation argumentCount

argumentCount = OsHostInput.argumentCount

Operation argument

argument = OsHostInput.argument

Operation variable

variable = OsHostInput.variable

Operation workingDirectory

workingDirectory = OsHostInput.workingDirectory

On this page