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

Function seekfrom

crates/vm/src/stdlib/_io.rs:253–267  ·  view source on GitHub ↗
(
        vm: &VirtualMachine,
        offset: PyObjectRef,
        how: OptionalArg<i32>,
    )

Source from the content-addressed store, hash-verified

251 const DEFAULT_BUFFER_SIZE: usize = super::DEFAULT_BUFFER_SIZE;
252
253 pub(super) fn seekfrom(
254 vm: &VirtualMachine,
255 offset: PyObjectRef,
256 how: OptionalArg<i32>,
257 ) -> PyResult<SeekFrom> {
258 let seek = match how {
259 OptionalArg::Present(0) | OptionalArg::Missing => {
260 SeekFrom::Start(offset.try_into_value(vm)?)
261 }
262 OptionalArg::Present(1) => SeekFrom::Current(offset.try_into_value(vm)?),
263 OptionalArg::Present(2) => SeekFrom::End(offset.try_into_value(vm)?),
264 _ => return Err(vm.new_value_error("invalid value for how")),
265 };
266 Ok(seek)
267 }
268
269 #[derive(Debug)]
270 struct BufferedIO {

Callers 1

seekMethod · 0.85

Calls 2

try_into_valueMethod · 0.80
ErrClass · 0.50

Tested by

no test coverage detected