silk/native_host_input
Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, x86_64-unknown-linux-gnu.
Owned native process-input snapshots and per-call working-directory lookup.
When to use
Capture arguments and environment at a hosted entry, then move the snapshot into a HostInput provider. Capture copies every byte so later lookups do not depend on foreign input lifetimes.
Gotchas
Capture is unsafe: input vectors and their NUL-terminated strings must remain readable and unchanged until it returns. Working-directory lookup observes the process at the time of call.
Import as NativeHostInput with import silk.native_host_input { NativeHostInput }.
Public declarations: 1.
NativeHostInput
pub struct NativeHostInputAn affine snapshot owning every argument and environment byte.
Associated function NativeHostInput.environmentSnapshot
pub unsafe effect<'static> fn environmentSnapshot() -> NativeHostInput ! HostInputError | OutOfMemoryError ? &mut AllocatorCopies the current libc environment into a snapshot with no arguments.
When to use
Use at a library boundary that receives no command line. Hosted entries should capture their actual argument vector with capture instead.
Gotchas
No foreign environment mutation may overlap this operation. Later lookups use owned bytes and need no access to libc's environment storage. A null environment means no variables.
Associated function NativeHostInput.captureProcess
pub unsafe effect<'static> fn captureProcess(argc: i32, argv: [*]const ?[*]const u8) -> NativeHostInput ! HostInputError | OutOfMemoryError ? &mut AllocatorCopies C entry arguments and the current libc environment into owned storage.
Gotchas
argv must remain readable through argc elements, and each element must point to an unchanged NUL-terminated string. No foreign environment mutation may overlap capture. Failure releases every partially copied argument and environment value.
Associated function NativeHostInput.capture
pub unsafe effect<'static> fn capture(argc: i32, argv: [*]const ?[*]const u8, environment: [*]const ?[*]const u8) -> NativeHostInput ! HostInputError | OutOfMemoryError ? &mut AllocatorCopies complete entry input vectors into independent owned storage.
Gotchas
The caller supplies readable argv elements through argc and environment elements through its null terminator. Every non-null element identifies a live NUL-terminated byte string. No foreign mutation may overlap capture. Failure releases every partially copied value.
Method NativeHostInput.argumentCount
pub fn argumentCount<'life0>(self: &'life0 NativeHostInput) -> usizeReturns the captured argument count, including the program name when present.
Method NativeHostInput.argument
pub fn argument<'life0, 'life1>(self: &'life0 NativeHostInput, index: usize, output: &'life1 mut [u8]) -> silk/option.Option<usize>Copies the fitting argument prefix and returns its full length, or None when absent.
Details
An empty argument is Some(0). Bytes beyond the committed prefix remain unchanged.
Method NativeHostInput.variable
pub fn variable<'life0, 'life1, 'life2>(self: &'life0 NativeHostInput, name: &'life1 [u8], output: &'life2 mut [u8]) -> silk/option.Option<usize>Copies the first matching environment value's prefix and returns its complete byte length.
Details
Matching is byte-exact. Missing names are None; empty values are Some(0). Names containing NUL or equals do not match. Malformed entries without equals are ignored.
Associated function NativeHostInput.workingDirectory
pub effect<'static> fn workingDirectory() -> Bytes ! HostInputError | OutOfMemoryError ? &mut AllocatorReads the current working directory into independently owned bytes.
Details
Grows from 256 bytes through 1 MiB only on ERANGE. Every attempt owns and releases its buffer. Allocation failure is OutOfMemoryError; other failures are HostInputError.
Associated function NativeHostInput.workingDirectoryCopy
pub effect<'life0> fn workingDirectoryCopy<'life0>(output: &'life0 mut [u8]) -> usize ! HostInputError | OutOfMemoryError ? &mut AllocatorCopies the fitting cwd prefix and reports its full length, leaving the remaining tail intact.