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

Method flush

crates/stdlib/src/mmap.rs:1007–1033  ·  view source on GitHub ↗
(&self, options: FlushOptions, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

1005
1006 #[pymethod]
1007 fn flush(&self, options: FlushOptions, vm: &VirtualMachine) -> PyResult<()> {
1008 let (offset, size) = options
1009 .values(self.__len__())
1010 .ok_or_else(|| vm.new_value_error("flush values out of range"))?;
1011
1012 if self.access == AccessMode::Read || self.access == AccessMode::Copy {
1013 return Ok(());
1014 }
1015
1016 match self.check_valid(vm)?.deref().as_ref().unwrap() {
1017 MmapObj::Read(_mmap) => {}
1018 MmapObj::Write(mmap) => {
1019 mmap.flush_range(offset, size)
1020 .map_err(|e| e.to_pyexception(vm))?;
1021 }
1022 #[cfg(windows)]
1023 MmapObj::Named(named) => {
1024 let ptr = unsafe { named.view_ptr.add(offset) };
1025 let result = unsafe { FlushViewOfFile(ptr as *const _, size) };
1026 if result == 0 {
1027 return Err(io::Error::last_os_error().to_pyexception(vm));
1028 }
1029 }
1030 }
1031
1032 Ok(())
1033 }
1034
1035 #[cfg(all(unix, not(target_os = "redox")))]
1036 #[pymethod]

Callers

nothing calls this directly

Calls 10

ok_or_elseMethod · 0.80
check_validMethod · 0.80
ErrClass · 0.50
valuesMethod · 0.45
__len__Method · 0.45
unwrapMethod · 0.45
as_refMethod · 0.45
derefMethod · 0.45
to_pyexceptionMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected