rustpython_vm/convert/
to_pyobject.rs1use crate::{builtins::PyBaseExceptionRef, PyObjectRef, PyResult, VirtualMachine};
2
3pub trait ToPyObject {
9 fn to_pyobject(self, vm: &VirtualMachine) -> PyObjectRef;
10}
11
12pub trait ToPyResult {
13 fn to_pyresult(self, vm: &VirtualMachine) -> PyResult;
14}
15
16pub trait ToPyException {
17 fn to_pyexception(&self, vm: &VirtualMachine) -> PyBaseExceptionRef;
18}
19
20pub trait IntoPyException {
21 fn into_pyexception(self, vm: &VirtualMachine) -> PyBaseExceptionRef;
22}
23
24impl<T> IntoPyException for &'_ T
25where
26 T: ToPyException,
27{
28 fn into_pyexception(self, vm: &VirtualMachine) -> PyBaseExceptionRef {
29 self.to_pyexception(vm)
30 }
31}