silk/os_standard_input
Native StandardInput provider backed by the process standard-input descriptor.
When to use
Construct OsStandardInput at a native application edge and provide it to portable byte-input
code. Use a scripted provider in tests to control partial reads, end-of-input, and failures.
Details
The provider owns no persistent state and commits each host read directly into the caller's
buffer. For a non-empty buffer, a zero-length host transfer becomes the outcome selected by
endOfInput. Only a host read error becomes StreamReadError. Partial transfer counts are
preserved exactly.
Constructing the provider performs no read. Portable code reads after the application supplies
&mut OsStandardInput for the &mut StandardInput requirement.
Gotchas
Reachable OS standard-input operations are native-only. Direct WebAssembly compilation rejects them instead of inventing a descriptor import. Evaluator execution requires an injected adapter. The caller must use a non-empty buffer. A zero-capacity host read also transfers zero bytes.
Examples
Construct the native provider without reading standard input
import silk.os_standard_input as OsStandardInput
pub fn main() -> i32 {
let provider = OsStandardInput.make()
drop provider
return 42
}Import as OsStandardInput with import silk.os_standard_input.
Public declarations: 2.
OsStandardInput
pub struct OsStandardInputA stateless native StandardInput provider for the process input descriptor.
Details
The process owns the descriptor. Each read changes only the committed prefix of the caller's buffer and preserves the host transfer count.
make
pub fn make() -> OsStandardInputCreates a stateless provider for native standard-input bytes.
When to use
Use this function at a native application edge. Provide the result as &mut StandardInput to
portable code that calls silk.standard_input.receive.
Details
Construction performs no read and cannot fail. For a non-empty read buffer, a later zero-byte
host transfer becomes end-of-input data. A host read error becomes StreamReadError.
Implementation StandardInput for OsStandardInput
impl StandardInput for OsStandardInputOperation read
read = OsStandardInput.read