silk/os_standard_input
Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, x86_64-unknown-linux-gnu.
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 remembers observed end-of-input and commits each libc read directly into the caller's
buffer. For a non-empty buffer, a zero-length host transfer becomes the outcome selected by
StandardInput.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
This module publishes its provider only for the supported native profiles. WebAssembly selection leaves the module empty. Empty buffers produce Filled(0) without reading, including after observed end-of-input. A fresh provider can observe descriptor changes after a previous provider latched end-of-input.
Examples
Construct the native provider without reading standard input
import silk.os_standard_input { OsStandardInput }
pub fn main() -> i32 {
let provider = OsStandardInput.make()
drop provider
return 42
}Import as OsStandardInput with import silk.os_standard_input { OsStandardInput }.
Public declarations: 1.
OsStandardInput
pub struct OsStandardInputA 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.
Associated function OsStandardInput.make
pub fn make() -> OsStandardInputCreates a 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 initializes only the EOF flag and cannot fail. For a non-empty read buffer, a 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