MCPcopy Create free account
hub / github.com/LibertyOS-Development/kernel / read

Method read

src/sys/console.rs:74–90  ·  view source on GitHub ↗

Read

(&mut self, buffer: &mut [u8])

Source from the content-addressed store, hash-verified

72{
73 // Read
74 fn read(&mut self, buffer: &mut [u8]) -> Result<usize, ()>
75 {
76 let mut s = if buffer.len() == 4
77 {
78 readchar().to_string()
79 }
80 else
81 {
82 readln()
83 };
84
85 s.truncate(buffer.len());
86 let n = s.len();
87 buffer[0..n].copy_from_slice(s.as_bytes());
88
89 Ok(n)
90 }
91
92 // Write
93 fn write(&mut self, buffer: &[u8]) -> Result<usize, ()>

Callers

nothing calls this directly

Calls 3

readcharFunction · 0.85
readlnFunction · 0.85
lenMethod · 0.45

Tested by

no test coverage detected