MCPcopy Index your code
hub / github.com/RustPython/RustPython / peek

Method peek

crates/vm/src/stdlib/_io.rs:1869–1878  ·  view source on GitHub ↗
(&self, _size: OptionalSize, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

1867
1868 #[pymethod]
1869 fn peek(&self, _size: OptionalSize, vm: &VirtualMachine) -> PyResult<Vec<u8>> {
1870 let mut data = self.reader().lock(vm)?;
1871 let raw = data.check_init(vm)?;
1872 ensure_unclosed(raw, "peek of closed file", vm)?;
1873
1874 if data.writable() {
1875 let _ = data.flush_rewind(vm);
1876 }
1877 data.peek(vm)
1878 }
1879
1880 #[pymethod]
1881 fn read1(&self, size: OptionalSize, vm: &VirtualMachine) -> PyResult<Vec<u8>> {

Callers

nothing calls this directly

Implementers 1

_io.rscrates/vm/src/stdlib/_io.rs

Calls 7

ensure_unclosedFunction · 0.85
check_initMethod · 0.80
flush_rewindMethod · 0.80
lockMethod · 0.45
readerMethod · 0.45
writableMethod · 0.45
peekMethod · 0.45

Tested by

no test coverage detected