// Standard input as bytes (ADR 0086), from stdin_bytes.stdin: after a // line, chunks of at most the size asked, any bytes (NUL, 0xff), then the // end. A size below one reads one byte. import std/bytes import std/io fn shown :: r: Result, io.Error> -> String { match r { Ok(Some(b)) -> "bytes " <> debug b , Ok(None) -> "end" , Error(e) -> "error " <> show e } } pub fn main :: -> () / { match io.read_line () { Ok(Some(line)) -> io.println ("line " <> debug line) , _ -> io.println "no line" } io.println (shown (io.read_bytes 4)) io.println (shown (io.read_bytes 0)) io.println (shown (io.read_bytes 100)) io.println (shown (io.read_bytes 100)) match io.read_line () { Ok(None) -> io.println "line: end", _ -> io.println "line: more?" } } //> line "line one" //> bytes b"rest" //> bytes b":" //> bytes b" \x00\x01\xff and more" //> end //> line: end